# [Bug 28845] fn:format-number, formatting rules for exponential notation

From: <bugzilla@jessica.w3.org>
Date: Fri, 17 Jul 2015 16:05:03 +0000

Message-ID: <bug-28845-523-L5HMrMEATS@http.www.w3.org/Bugs/Public/>
```https://www.w3.org/Bugs/Public/show_bug.cgi?id=28845

--- Comment #4 from Michael Kay <mike@saxonica.com> ---
We walked through test case numberformat135 in the WG as follows.

The test is

fn:format-number(0.2, '#.e9')

4.7.4 Analyzing the picture string:

* integer-part-grouping-positions = empty set

* minimum-integer-part-size = 1

* prefix = ""

* fractional-part-grouping-positions = empty set

* minimum-fractional-part-size = 0

* maximum-fractional-part-size = 0

* minimum-exponent-size = 1

* suffix = ""

4.7.5 Formatting the number

1. If the input number is NaN - N/A

2. The positive sub-picture is used if the input number is positive

3. If the sub-picture contains a percent-sign: N/A

4. If the minimum exponent size is non-zero, then the adjusted number is scaled
to establish a mantissa and an integer exponent.

mantissa = 0.2, exponent = 0

5. The mantissa is converted (if necessary) to an xs:decimal value: no
conversion needed.

6. The absolute value of the rounded number is converted to a string in decimal
notation: ".2". ** Here I think we went wrong. We missed the sentence "This
value is then rounded so that it uses no more than maximum-fractional-part-size
digits in its fractional part. " Corrected result: "."

7. If the number of digits to the right of the decimal-separator-sign is less
than minimum-fractional-part-size: N/A

8. For each integer N in the integer-part-grouping-positions list: no action

9. For each integer N in the fractional-part-grouping-positions list: no action

10. If there is no decimal-separator-sign in the sub-picture, or if there are
no digits to the right of the decimal-separator-sign character in the string:
Original analysis: N/A. Corrected analysis: The string is now "".

11. If an exponent exists, then the string produced from the mantissa as
described above is extended with the following, in order: (a) the exponent
separator sign; (b) if the exponent is negative, the minus sign; (c) the value
of the exponent represented as a decimal integer, extended if necessary with
leading zeroes to make it up to the minimum exponent size, using digits taken
from the decimal digit family. => ".2e0" Corrected analysis: "e0"

12. The result of the function is the concatenation of the appropriate prefix,
the string conversion of the number as obtained above, and the appropriate
suffix. => .2e0. Corrected analysis: "e0"

A strange result perhaps, but you get what you ask for.

--
You are receiving this mail because:
You are the QA Contact for the bug.
```
Received on Friday, 17 July 2015 16:05:06 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:55 UTC