lua-users home
lua-l archive

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




On Sep 18, 2019, at 9:12 PM, Coda Highland <chighland@gmail.com> wrote:



On Wed, Sep 18, 2019 at 3:06 PM Tim Hill <drtimhill@gmail.com> wrote:


On Sep 18, 2019, at 6:24 PM, Coda Highland <chighland@gmail.com> wrote:



On Wed, Sep 18, 2019 at 12:21 PM Coda Highland <chighland@gmail.com> wrote:
However, there are six different ways that a C implementation could choose to implement number formatting, five of which are documented in IEEE-754:
* Round towards 0
* Round towards +inf
* Round towards -inf
* Round towards nearest, ties to even
* Round towards nearest, ties away from 0
* Truncate decimal representation

It occurs to me that truncating the decimal representation is actually equivalent to rounding towards 0, so that's only five after all and all of them are documented. Wasn't thinking about that.

/s/ Adam

Not for negative numbers.

Yes for negative numbers. If you write -1.23456, and you truncate that representation (e.g. to -1.23), then you have rounded towards zero.

Besides, if it WERE different for negative numbers, then it would be equivalent to rounding towards -inf instead, which would still mean it's not a distinct rounding mode.

/s/ Adam

Lol you’re right. What WAS I drinking last night? :)

—Tim