Hey,
I've got an easy question for you for a change! When you typecast doubles to ints, does the compiler truncate the value or round the value? If I remember correctly this is compiler specific.
Example:
...
double num1=10.5;
int num2=(int)num1;
...
Does num2 become 10 or 11? Let me know,
James
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
[Z88dk-users] Conversion from double to int
On Fri, 19 Mar 2004, James King wrote:
You think that's an easy question? <grin>
I believe genmath floor()s the number so truncation.
The other maths libraries (ZX,cpc,z88) call the appropriate maths routine
in the ROM, I'm guessing that they also truncate.
cheers,
d.
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
Hey, I've got an easy question for you for a change! When you typecast
doubles to ints, does the compiler truncate the value or round the
value? If I remember correctly this is compiler specific.
You think that's an easy question? <grin>
I believe genmath floor()s the number so truncation.
The other maths libraries (ZX,cpc,z88) call the appropriate maths routine
in the ROM, I'm guessing that they also truncate.
cheers,
d.
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click