W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2010

[whatwg] valueAsNumber: float is not enough

From: TAMURA, Kent <tkent@chromium.org>
Date: Tue, 26 Jan 2010 17:07:43 +0900
Message-ID: <b7b4ecf81001260007n3d3b769clb9c5c1c8f2c2f1b6@mail.gmail.com>
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>
Received on Tuesday, 26 January 2010 00:07:43 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:20 UTC