[whatwg] valueAsNumber: float is not enough

TAMURA, Kent tkent at chromium.org
Tue Jan 26 00:07:43 PST 2010


http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#the-input-element
<http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#the-input-element>

          attribute float valueAsNumber  
<http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#dom-input-valueasnumber>;


valueAsNumber is defined as float, IEEE754 single precision number.
It should be double because number values for date and time types are
milliseconds from UNIX epoch.  As of today, milliseconds from UNIX epoch is
about 1,264,492,163,000.  The float type can't represent this value
precisely.
If we do the following with float valueAsNumber, the input value loses the
data.
   input.type = "datetime";
   input.value = "2010-01-26T08:00Z";
   var num = input.valueAsNumber;
   input.valueAsNumber = num;

-- 
TAMURA Kent
Software Engineer, Google



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100126/2c6e00a8/attachment.htm>


More information about the whatwg mailing list