Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compiler option to convert int to double with DiabC/C++

Status
Not open for further replies.

1230

Programmer
Apr 23, 2001
5
FR
I'm use DiabC/C++
i have no error and warning during compile, but when my program is running, there is an error in conversion int to double, like this:

double a=0.0;
int b=1;

a =(double)b; there is error..........
a=(double)b*0.1/0.1 there is error..........


the error should be a compiler option, but i can't find it.
 
Thats odd... try getting rid of the cast and see what happens. Promotion from int to double should produce no warnings or errors. If they still exist, it must be an option and search the help for promoting integers

Matt
 
Check the code for smaller more insignificant errors. It may not be that this code ever produces any error with or without cast it is working fine on my PC.


probably semicolon etc.....

SwapSawe
 
I've had a friend who found a bug in the Diab compiler, but I think it was something else which only appeared when some optimization options were on. The code above looks fine. If you're using C, remember to keep all your unitialized variables at the top of the functions and the initialized variables following them, before any executable statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top