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

From: <bugzilla@jessica.w3.org>
Date: Wed, 24 Jun 2015 09:20:46 +0000

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

Bug ID: 28845
Summary: fn:format-number, formatting rules for exponential
notation
Product: XPath / XQuery / XSLT
Version: Candidate Recommendation
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P2
Component: Functions and Operators 3.1
Assignee: mike@saxonica.com
Reporter: christian.gruen@gmail.com

I have a slightly hard time understanding the formatting semantics for the new
exponential notation of fn:format-number. This the current wording for Rule 4
and 5:
_______________________________________________

4. If the sub-picture contains a percent-sign, the number is multiplied by 100.
If the sub-picture contains a per-mille-sign, the number is multiplied by 1000.
The resulting number is referred to below as the adjusted number.

5. If the minimum exponent size is non-zero, then the adjusted number is scaled
to establish a mantissa and an integer exponent. The mantissa and exponent are
chosen such that

(a) the primitive type of the mantissa is the same as the primitive type of
the adjusted number (integer, decimal, float, or double),
(b) the mantissa multiplied by ten to the power of the exponent is equal to
the adjusted number, and
(c) the number of significant digits in the integer part of the mantissa is
equal to the minimum integer part size.
_______________________________________________

- Rule 4: The following sentence could be added (provided that it's correct):
"If there is no percent-sign or per-mille-sign, the adjusted number will be
equal to the original number."

- Rule 5a is clear, but 5b and 5c is a bit confusing to me (although I'm sorry
I cannot provide a better solution yet, because I don't understand the exact
semantics yet). Is the leading zero of a number larger than 0 and smaller than
1 a "significant digit"? What is going to happen if the minimum integer part
size is 0 and if there are optional digit signs in the integer part of the
pattern? In the current test cases "numberformat135" and "numberformat136"...

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

...the expected result is "2e-1". Is the result correct for both test cases?