Directed rounding

Martin von Gagern gagern at
Wed Aug 26 16:01:25 UTC 2015

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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the es-discuss mailing list