Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 10th, 2004, 4:09 PM   #1
BlueRaja
Newbie
 
Join Date: Oct 2004
Posts: 2
Rep Power: 0 BlueRaja is on a distinguished road
I have a conditional similar to the following:
#define OTHER_NUMBER 300
...
float MyFunction(int);
...
if (MyFunction(somenumber)==OTHER_NUMBER)
MyFunction is returning a value of 300.000 (confirmed by my wonderful debugger ^_^); however, the conditional is being evaluated as false. I've also tried the following:
#define OTHER_NUMBER 300.000
if ((int)MyFunction(somenumber)==OTHER_NUMBER)
if (MyFunction(somenumber)==(float)OTHER_NUMBER)
if (static_cast<int>(MyFunction(somenumber))==OTHER_NUMBER)//I'm not even quite sure what static_cast does...
But to no avail...
Any ideas? Thanks in advance.
__________________
<span style='color:red'>AKhalifman@hotmail.com</span>
BlueRaja is offline   Reply With Quote
Old Oct 11th, 2004, 10:07 AM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
You can either declare the function as int, or typecast it to an integer by placing (int) in front of the function call:

if ((int)MyFunction(somenumber) == OTHER_NUMBER)
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:53 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC