Double-to-integer conversion behavior and options

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.

-Boris

Received on Tuesday, 23 August 2011 03:47:52 UTC