Skip to content

Commit

Permalink
do not apply large_notation to 0: #602
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Sep 20, 2024
1 parent a6e3011 commit 68fb54d
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 59 deletions.
3 changes: 2 additions & 1 deletion lib/isodoc/presentation_function/math.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ def large_notation_fmt(symbols, num)
end

def large_notation_fmt1(num, notation, min, max)
notation.nil? || notation == "nil" and return
notation.nil? || notation == "nil" and return nil
val = BigDecimal(num).abs
val.zero? and return nil
val < min and return notation
val > max and return notation
nil
Expand Down
124 changes: 66 additions & 58 deletions spec/isodoc/presentation_xml_maths_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@
</bibdata>
<preface>
<p>
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML">
<mn data-metanorma-numberformat="notation='basic'">0.0</mn>
</math></stem>
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML">
<mn data-metanorma-numberformat="notation='basic'">0.31e2</mn>
</math></stem>
Expand Down Expand Up @@ -495,6 +498,7 @@
<preface>
<clause type="toc" id="_" displayorder="1"> <title depth="1">Table of contents</title> </clause>
<p displayorder="2">
0.00
31.00
327,428.74
327,428.74
Expand Down Expand Up @@ -567,6 +571,7 @@
<preface>
<clause type="toc" id="_" displayorder="1"> <title depth="1">Table of contents</title> </clause>
<p displayorder="2">
0.0
31
327,428.74'32'87'84'32'99'2
327,428.74'32'87'84'32'99'2
Expand Down Expand Up @@ -639,6 +644,7 @@
<preface>
<clause type="toc" id="_" displayorder="1"> <title depth="1">Table of contents</title> </clause>
<p displayorder="2">
0.0
31
327,428.74'32'87'84'32'99'2
327,428.74'32'87'84'32'99'2
Expand Down Expand Up @@ -706,64 +712,66 @@
}))

output1 = <<~OUTPUT
<iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
<bibdata>
<title language='en'>test</title>
</bibdata>
<preface>
<clause type="toc" id="_" displayorder="1"> <title depth="1">Table of contents</title> </clause>
<p displayorder="2">
31 3.27'42'87'43'28'78'43'29'92 × 10<sup>5</sup>
3.27'42'87'43'28'78'43'29'92 × 10<sup>5</sup>
3.27 × 10<sup>5</sup>
3.27'42'87'43 × 10<sup>5</sup>
3.27 × 10<sup>5</sup>
3.27'42'87'43 × 10<sup>5</sup>
3.27'4 × 10<sup>5</sup>
3.27 × 10<sup>5</sup>
3,27'42'87'43 × 10<sup>5</sup>
3.27 × 10<sup>5</sup>
3,27'42'87'43 × 10<sup>5</sup>
3,27'4 × 10<sup>5</sup>
1 1,1 1,10'0 1 × 10<sup>21</sup>
1,0 × 10<sup>19</sup>
1,0 × 10<sup>-19</sup>
3.27 × 10<sup>5</sup>
3,27'42'87'43 × 10<sup>5</sup>
3.27 × 10<sup>5</sup>
3,27'42'87'43 × 10<sup>5</sup>
3,27'4 × 10<sup>5</sup>
1e0
1,1e0
1,10'0e0
1 × 10<sup>21</sup>
1,0 × 10<sup>19</sup>
1,0 × 10<sup>-19</sup>
... 6,4212y1490y0 × 10<sup>17</sup>
6,4212y1490y0 × 10<sup>17</sup>
6,4212y1490y0 × 10<sup>+17</sup>
642,1214y967 × 10<sup>15</sup>
6,42'12'14'96'8 × 10<sup>17</sup>
6,4212y1490y0 × 10<sup>-20</sup>
6,4212y1490y0 × 10<sup>-20</sup>
6,4212y1490y0 × 10<sup>-20</sup>
6,42'12'14'96'8 × 10<sup>-20</sup>
<stem type="MathML">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msqrt>
<msup>
<mn>6,42'12'14'96'8 × 10</mn>
<mn>-20</mn>
</msup>
</msqrt>
</math>
<asciimath>sqrt(0.6421214967726451564515e-19)</asciimath>
</stem>
3,00'00 × 10
<sup>4</sup>
</p>
</preface>
</iso-standard>
<iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
<bibdata>
<title language='en'>test</title>
</bibdata>
<preface>
<clause type="toc" id="_" displayorder="1"> <title depth="1">Table of contents</title> </clause>
<p displayorder="2">
0.0
31
3.27'42'87'43'28'78'43'29'92 × 10<sup>5</sup>
3.27'42'87'43'28'78'43'29'92 × 10<sup>5</sup>
3.27 × 10<sup>5</sup>
3.27'42'87'43 × 10<sup>5</sup>
3.27 × 10<sup>5</sup>
3.27'42'87'43 × 10<sup>5</sup>
3.27'4 × 10<sup>5</sup>
3.27 × 10<sup>5</sup>
3,27'42'87'43 × 10<sup>5</sup>
3.27 × 10<sup>5</sup>
3,27'42'87'43 × 10<sup>5</sup>
3,27'4 × 10<sup>5</sup>
1 1,1 1,10'0 1 × 10<sup>21</sup>
1,0 × 10<sup>19</sup>
1,0 × 10<sup>-19</sup>
3.27 × 10<sup>5</sup>
3,27'42'87'43 × 10<sup>5</sup>
3.27 × 10<sup>5</sup>
3,27'42'87'43 × 10<sup>5</sup>
3,27'4 × 10<sup>5</sup>
1e0
1,1e0
1,10'0e0
1 × 10<sup>21</sup>
1,0 × 10<sup>19</sup>
1,0 × 10<sup>-19</sup>
... 6,4212y1490y0 × 10<sup>17</sup>
6,4212y1490y0 × 10<sup>17</sup>
6,4212y1490y0 × 10<sup>+17</sup>
642,1214y967 × 10<sup>15</sup>
6,42'12'14'96'8 × 10<sup>17</sup>
6,4212y1490y0 × 10<sup>-20</sup>
6,4212y1490y0 × 10<sup>-20</sup>
6,4212y1490y0 × 10<sup>-20</sup>
6,42'12'14'96'8 × 10<sup>-20</sup>
<stem type="MathML">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msqrt>
<msup>
<mn>6,42'12'14'96'8 × 10</mn>
<mn>-20</mn>
</msup>
</msqrt>
</math>
<asciimath>sqrt(0.6421214967726451564515e-19)</asciimath>
</stem>
3,00'00 × 10
<sup>4</sup>
</p>
</preface>
</iso-standard>
OUTPUT
TwitterCldr.reset_locale_fallbacks

Expand Down

0 comments on commit 68fb54d

Please sign in to comment.