Directed rounding

Waldemar Horwat waldemar at google.com
Wed Aug 26 21:37:12 UTC 2015


On 08/26/2015 13:12, C. Scott Ananian wrote:
> I think the "better idea" would be related to value types (http://www.slideshare.net/BrendanEich/value-objects2) which brendan is working on for ES7.
> I fuzzily recall rounding modes being used as an example in one of these slide decks, perhaps I am misremembering.
>
> At any rate, one option would be for "round down float" and "round up float" to be separate value types.  It seems broadly similar to your proposal, except that you could use actual operators.  The lower range in an interval would be a "round down float" and the upper range a "round up float".

It doesn't make sense to encode a rounding mode such as "round down" into a value type.  If you multiply it by -1, half of the time it will start doing the wrong thing.

Instead, you want functions that perform the primitive operations (+, -, *, /, sqrt, sin, etc.) in a rounding mode specified by the name of the function or perhaps a third parameter.  This must be stateless, not carrying a rounding mode with a value or (even worse) in some global environment.

     Waldemar



More information about the es-discuss mailing list