W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2011

Re: Double-to-integer conversion behavior and options

From: Jonas Sicking <jonas@sicking.cc>
Date: Mon, 22 Aug 2011 21:52:22 -0700
Message-ID: <CA+c2ei83VX2J2XRUhG28hmVaEUsnBU1CA4HZMvsUkuMHUxPHTg@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
On Mon, Aug 22, 2011 at 8:47 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> Two changes I was talking to Cameron about that might be worth considering
> for WebIDL:
>
> 1)  [Clamp] conversions should probably round to nearest, ties to even,
> instead of flooring.  Otherwise you introduce persistent bias toward zero on
> floating-point rounding errors, whereas [Clamp] sort of requests sane
> behavior.
>
> 2)  We should introduce some sort of [EnforceRange] so that specs can
> declare range restrictions that involve throwing when out of range (as
> opposed to clamping, which [Clamp] handles) in the IDL.  This should
> presumably throw after rounding toward 0 (instead of doing a floor) so that
> the common case of wanting to enforce a nonnegative number with exceptions
> when negative will work ok in the presence of small roundoff errors.

Can you give examples of when you'd use these? I can't think of any
APIs off the top of my head which would take an argument which both

1. Is an integer
2. The calling page would be likely to calculate the argument value
using non-integer math.

In other words, it would seem ok to me to throw for any integer
argument which was passed a non-integer.

/ Jonas
Received on Tuesday, 23 August 2011 04:53:27 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:04 UTC