lua-users home
lua-l archive

Re: Why do some math functions return -0

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


Quoth Mike McGonagle <mjmogo@gmail.com>, on 2010年09月19日 11:19:59 -0400:
> Hello all,
> 
> I have been doing some very simple things (mostly to get the integer
> portion of a number) using math.floor, and it seems that sometimes the
> function will return -0, when I am expecting a 0. Can someone please
> explain why this happens? Is there a logical reason for this?
Why wouldn't they? Negative and positive zero are two floating-point
representations with the same closest real number.
Can you give a specific example?
> Thanks,
> 
> Mike
 ---> Drake Wilson

AltStyle によって変換されたページ (->オリジナル) /