Re: Double-to-integer conversion behavior and options

On 8/23/11 12:52 AM, Jonas Sicking wrote:
> 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.

Canvas imagedata comes to mind.  That's the primary consumer of [Clamp] 
at the moment.  I'd think audio APIs would also take integer amplitudes 
or whatnot but commonly have those computed using non-integer math.

Also, things like HTMLImageElement.width/height can easily end up being 
computed to non-integers, and certainly using non-integer math leading 
to rounding errors.

I'm not sure what the throwing use cases are, but Cameron said there 
were specs defining that sort of behavior in prose (so defining APIs 
that take signed ints but throwing for negative values).

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

I doubt that's web-compatible.  Certainly not for canvas imagedata.


Received on Tuesday, 23 August 2011 05:02:04 UTC