Directed rounding

C. Scott Ananian ecmascript at
Wed Aug 26 20:12:25 UTC 2015

I think the "better idea" would be related to value types ( 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

On Wed, Aug 26, 2015 at 12:01 PM, Martin von Gagern <gagern at>

> Hello Scott,
> Thanks for the comment!
> On 26.08.2015 17:22, C. Scott Ananian wrote:
> > `fesetround` would be a terrible way for JavaScript to implement this,
> I agree, the stateful nature of rounding mode is a pain, and should be
> kept in a tightly closed locker. I was more thinking about a method
> which sets the rounding mode to something specific, then performs one
> particular operation in that mode before resetting the mode to default.
> This would encapsulate the needed functionality without exposing its
> stateful nature. Of course engines would be encouraged to detect
> sequences of calls to such intrinsics, and to avoid the mode changes
> between operations with the same mode. But that's just implementation
> improvements for the sake of performance, once the semantics are there.
> > I believe there have been proposals to allow greater access to IEEE
> > floating point intrinsics, and I suspect they were better engineered for
> > modularity.
> Better engineered than fesetround? That's easy, I think. Better
> engineered than my post? Easy as well, since I kept it to the bare
> minimum. My previous post was more detailed. See
> or perhaps this example
> from that post:
> ```
>   const down = Math.directedRounding("-Infinity");
>   const up = Math.directedRounding("+Infinity");
>   function interval(lo, hi) { this.lo = lo; this.hi = hi; }
>   interval.prototype.add = function(that) {
>       return new interval(down.add(this.lo, that.lo),
>                           up.add(this.hi, that.hi));
>   }
> ```
> > Perhaps one of the other readers of this list remembers
> > enough details to give you a good citation.
> I would welcome any pointers in this regard. Searching the Gmane
> archives, I couldn't find any. Perhaps that was because many search term
> combinations I could think of resulted in lots of messages dealing with
> decimal arithmetic, one way or another.
> Greetings,
>  Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list