HTML5 progress range of max and value: too large values?

207 views Asked by At

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)?

1

There are 1 answers

0
Ortomala Lokni On BEST ANSWER

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.