Mail Archives: djgpp/1996/11/20/15:48:24
On Tue, 19 Nov 1996 14:25:04 GMT martin DOT gumucio AT mcu DOT uu DOT se (Martin
Gumucio) writes:
>
>I'm just learning c++ but djgpp is complaining on my coding...
>
>this source is copied right out of my book
>
>int auks;
>auks = 19.99 + 11.99;
>
>
>this is the commandline i use
>
>gxx SAMPLE.CPP -o SAMPLE.EXE -lm
>
>and this came out of the compiler
>utypomv.cpp: In function `int main()':
>utypomv.cpp:10: warning: assignment to `int' from `double'
>
>it simply refuses to make me use type casting of any form.
>Where can i find a list of all djgpp compiler errorsmessages?
You are using 2 floating point numbers, adding them together and putting
them in an integer. An integer is for non floting point numbers, change
your code to one of these:
float auks;
auks = 19.99 + 11.99;
or
int auks;
auks = (float)(19.99 + 11.99);
that will work, but the latter wil end up with the result of 31, while
the first code segment will come out to the answer you desire, 31.98;
---------------------------------------------------------------------------------------------------------------
MSnakes AT juno DOT com (Matt Reiferson)
Visit The Best Game Programming Web Page (GREAT FOR BEGINNERS)
http://members.aol.com/mreiferson
--------------------------------------------------------------------------------------------------------------
- Raw text -