www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/20/15:48:24

To: martin DOT gumucio AT mcu DOT uu DOT se, djgpp AT delorie DOT com
Date: Tue, 19 Nov 1996 19:50:32 PST
Subject: Re: list of djgpp compiler errors wanted!
Message-ID: <19961120.153203.14446.0.MSnakes@juno.com>
References: <32905cab DOT 10273409 AT news DOT uu DOT se>
From: msnakes AT juno DOT com (Matt J Reiferson)

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019