Benjamin P.
Benjamin P.

Reputation: 453

Firefox displays value in a input type number different then the one written in html

We have a simple input field with the type number. When we display large numbers the value that is visible in the element is different to the one that is in the field. This only happens on firefox (testet with version 30.0).

If I have following code the value written in html is 9999999999999999 but firefox displays 10000000000000000.

<input type="number" min="0" max="9999999999999999" value="9999999999999999">

Is there any solution to show a numeric input field on mobile devices without the type number or solve this problem?

jsfiddle

Upvotes: 1

Views: 628

Answers (1)

Alex
Alex

Reputation: 11245

Just try fiddle in FF and Chrome:

alert(9999999999999999);//return 10000000000000000
alert(999999999999999);//return 999999999999999

I think it's a IEEE 754 spec "feature" (like 0.1 + 0.2). Try IEEE 754 converter and you will see why result was changed.

Upvotes: 1

Related Questions