1

Consider the following MWE:

<!DOCTYPE html>
<html>
<head>
<title>Progress test</title>
</head>

<body>

<progress id="progress"></progress>

<script>
progress.max = 10000000000;
progress.value = 10000000000 / 2;
</script>

</body>
</html>

This used to work in Internet Explorer, Mozilla Firefox, Google Chrome, and Opera. But today I realised that it no longer works in Google Chrome; apparently, the values 10000000000 and 10000000000 / 2 are too large.

This made me wonder what the official specifications have to say about this. Do they guarantee that numbers this large should work (in this case, there is a bug in Google Chrome), or are my numbers above the largest value that is guaranteed to work (in this case, I am simply lucky that it works in IE and FF)?

Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384
  • you only need a number as large as the # of pixels wide anyway, convert to percent and move on. – dandavis Jun 22 '15 at 22:21
  • @dandavis: You are right that the workaround is obvious, but since I am interested in specifications I'd like to know precisely what is guaranteed here. – Andreas Rejbrand Jun 22 '15 at 22:23
  • says `attribute double max;` in the spec (which should work since 10000000000 < Number.MAX_SAFE_INTEGER ) – dandavis Jun 22 '15 at 22:24
  • @dandavis: Thank you, so it is a bug (although one that will only appear in a small number of all examples). – Andreas Rejbrand Jun 22 '15 at 22:28
  • I think it also says something like *"non-negative floating-point number"*, and that as long as it's a valid float, it should be ok, which means anything under `9007199254740992`, but there's no real limitation in absolute numbers in the spec, it's probably what they call "vendor specific", or up to the browser, and seeing as you might as well just use `1` instead of `10000000000` they probably thought supporting such large numbers was nonsense? – adeneo Jun 22 '15 at 22:28

1 Answers1

0

The HTML5 specification says about the progress element:

The value and max attributes, when present, must have values that are valid floating-point numbers.

A floating-point number is defined by:

A string is a valid floating-point number if it consists of:

Optionally, a "-" (U+002D) character. One or both of the following, in the given order: A series of one or more ASCII digits. A single "." (U+002E) character. A series of one or more ASCII digits. Optionally: Either a "e" (U+0065) character or a "E" (U+0045) character. Optionally, a "-" (U+002D) character or "+" (U+002B) character. A series of one or more ASCII digits.

Later, it'said that the algorithm for parsing floating-point number values should choose a value from the set of IEEE 754 double-precision floating-point numbers.

According to the question:

biggest integer that can be stored in a double

the maximum value for IEEE 754 double precision is approximately 1.8 × 10^308. So your number 10000000000 is largely is small enough to be represented in IEEE 754 double precision and should be correctly interpreted by any valid HTML5 browser.

Community
  • 1
  • 1
Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240