Re: Int cast / floating point isuses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for the info Brian.

If I was to round when compiling with gcc on x86 instead of using an int 
cast in situations where my application is running on different 
platforms and or compiled with different compilers they would still be 
truncating numbers such as 2.7777777777777 to create 2.777777 while the 
gcc numbers will become 2.777778. I will no longer have an error with 
the numbers that were exact to begin with but I will now have rounded 
numbers instead of truncated numbers.

Which brings me to ask the question, if trunc is truncating the number 
accurately then why doesn't int cast and is there a way to replicate 
this 64 bit behavior the other architectures use when using int cast on x86?

I guess in my situation, even if the 80 bit extended precision registers 
are supposed to be more accurate/precise overall, the accuracy/precision 
is not as important to me than having a number print out the same 
regardless of the platform it is running on, which really is my main goal.

Cheers,
Joe

Brian Gough wrote on 7/24/2004, 7:55 AM:

 > Use the rint type functions to round to the nearest integer reliably.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux