about 'round' function on mingw
Tatsuro MATSUOKA
tmacchant at yahoo.co.jp
Thu Apr 24 18:04:20 CDT 2008
Hello
I have posted to the topic round function on mingwML.
Sorry my poor knowldge prevent to answer the reply.
Please tell me what I should answer.
Regards
Tatsuro
"Greg Chicares" <gchicares at sbcglobal.net> wrote
On 2008-04-24 20:59Z, Tatsuro MATSUOKA wrote:
>
>> | The code used internally by MinGW for "round" is the following
>> | (http://www.koders.com/c/fidB63EAFA2C117AAFC1CF9FE9691F8DDBE4DD01A22.aspx)
>> |
>> | double
>> | round (double x)
>> | {
>> | /* Add +/- 0.5 then then round towards zero. */
>> | return trunc ( x + (x >= 0.0 ? 0.5 : -0.5));
>> | }
>> |
>> | The problem with this implementation is when x is the vicinity of bitmax: it
>> | leads to floating-point overflow (in the mantissa) and produces rounding error,
>> | For instance if x = bitmax, round(x) => bitmax+1, while it should return
>> | bitmax.
Please say very precisely what "bitmax" means, so that I can
write a minimal standalone testcase for your exact problem
without trying to build your package. I'd guess you mean the
largest normalized floating-point number, but without seeing
its hexadecimal representation, I can't be sure.
--------------------------------------
GANBARE! NIPPON! Win your ticket to Olympic Games 2008.
http://pr.mail.yahoo.co.jp/ganbare-nippon/
More information about the Help-octave
mailing list