You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: FORMULA-SUPPORT.md
+4-8Lines changed: 4 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -847,24 +847,20 @@ Output: 100. apple
847
847
848
848
### Base Conversions
849
849
850
-
Built-in functions for converting between decimal and hexadecimal, binary, octal, or Roman numerals. Each base has a pair of functions: `numXXX` for *to-string*output, `XXXnum` for parsing back to a number.
850
+
Built-in functions for parsing hexadecimal, binary, octal, or Roman numerals back to a number, plus Roman output. The decimal-to-hex/bin/oct *output* direction is handled by the format spec `~ x` / `~ b` / `~ o` (see the Number formatting section), so there is no `num2hex`-style built-in.
|`rom2num(s)`| number |`rom2num('MMXXIV')` → `2024`|
862
859
863
860
**Output conventions:**
864
-
- Hex/bin/oct outputs are **bare lowercase** — no `0x` / `0b` / `0o` prefix. Compose prefixes if you want them: `(?='0x' + num2hex(num(1)))`.
861
+
- Hex/bin/oct output via `~ x` / `~ b` / `~ o` is **bare lowercase** — no `0x` / `0b` / `0o` prefix. Compose prefixes if you want them: `(?='0x' + num(1) ~ x)`.
865
862
- Roman output is **uppercase canonical** form (subtractive pairs `IV`, `IX`, `XL`, etc.).
866
-
- Negative inputs to the bases produce `"-<digits>"` (e.g. `num2hex(-15)` → `"-f"`). For Roman, only the range 1..3999 is meaningful; out of range returns an empty string.
867
-
- Float inputs truncate toward zero (`num2hex(15.7) == num2hex(15)`).
863
+
- For Roman, only the range 1..3999 is meaningful; out of range returns an empty string.
868
864
869
865
**Parser conventions:**
870
866
-`hex2num`, `bin2num`, `oct2num` accept input **case-insensitively**, with or without the matching prefix, and trim surrounding whitespace. Invalid characters for the target base yield `NaN`.
@@ -875,7 +871,7 @@ Built-in functions for converting between decimal and hexadecimal, binary, octal
<p>String sources include literals in single quotes, the string variables (<code>FPATH</code>, <code>FNAME</code>), <code>txt(N)</code> capture text (use <code>txt(0)</code> for the full match), <code>txtcol(...)</code> CSV columns, and the conversion functions (<code>num2hex</code>, <code>num2rom</code>, etc.). The <code>+</code> operator concatenates strings.</p>
2020
+
<p>String sources include literals in single quotes, the string variables (<code>FPATH</code>, <code>FNAME</code>), <code>txt(N)</code> capture text (use <code>txt(0)</code> for the full match), <code>txtcol(...)</code> CSV columns, and the conversion functions (<code>num2rom</code>, <code>hex2num</code>, etc.). The <code>+</code> operator concatenates strings.</p>
2021
2021
<p>The legacy form <code>(?=return [a, b, c])</code> still compiles and behaves the same as <code>(?=a + b + c)</code>; new expressions should prefer the direct form.</p>
2022
2022
<sectionclass="note">
2023
2023
<p><strong>String literals are ASCII-only.</strong> UTF-8 bytes in <code>'...'</code> will fail to compile. Non-ASCII text must come from the document via captures or string variables, or be placed in the literal portion of the replace string outside <code>(?=...)</code>. See <ahref="#exprtk-limitations">Limitations</a> below.</p>
<p>Built-in functions for converting between decimal and hexadecimal, binary, octal, or Roman numerals. Each base has a pair of functions: <code>numXXX</code>for <em>to-string</em> output,<code>XXXnum</code>for parsing back to a number.</p>
2103
+
<p>Built-in functions for parsing hexadecimal, binary, octal, or Roman numerals back to a number, plus Roman output. The decimal-to-hex/bin/oct <em>output</em> direction is handled by the format spec <code>~ x</code>/ <code>~ b</code> /<code>~ o</code>(see the Number formatting section), so there is no <code>num2hex</code>-style built-in.</p>
<li>Hex/bin/oct outputs are <strong>bare lowercase</strong> — no <code>0x</code> / <code>0b</code> / <code>0o</code> prefix. Compose prefixes if you want them: <code>(?='0x' + num2hex(num(1)))</code>.</li>
2138
+
<li>Hex/bin/oct output via <code>~ x</code> / <code>~ b</code> / <code>~ o</code> is <strong>bare lowercase</strong> — no <code>0x</code> / <code>0b</code> / <code>0o</code> prefix. Compose prefixes if you want them: <code>(?='0x' + num(1) ~ x)</code>.</li>
2154
2139
<li>Roman output is <strong>uppercase canonical</strong> form (subtractive pairs <code>IV</code>, <code>IX</code>, <code>XL</code>, etc.).</li>
2155
-
<li>Negative inputs to the bases produce <code>"-<digits>"</code> (e.g. <code>num2hex(-15)</code> → <code>"-f"</code>). For Roman, only the range 1..3999 is meaningful; out of range returns an empty string.</li>
2156
-
<li>Float inputs truncate toward zero (<code>num2hex(15.7) == num2hex(15)</code>).</li>
2140
+
<li>For Roman, only the range 1..3999 is meaningful; out of range returns an empty string.</li>
<p>String sources include literals in single quotes, the string variables (<code>FPATH</code>, <code>FNAME</code>), <code>txt(N)</code> capture text (use <code>txt(0)</code> for the full match), <code>txtcol(...)</code> CSV columns, and the conversion functions (<code>num2hex</code>, <code>num2rom</code>, etc.). The <code>+</code> operator concatenates strings.</p>
2020
+
<p>String sources include literals in single quotes, the string variables (<code>FPATH</code>, <code>FNAME</code>), <code>txt(N)</code> capture text (use <code>txt(0)</code> for the full match), <code>txtcol(...)</code> CSV columns, and the conversion functions (<code>num2rom</code>, <code>hex2num</code>, etc.). The <code>+</code> operator concatenates strings.</p>
2021
2021
<p>The legacy form <code>(?=return [a, b, c])</code> still compiles and behaves the same as <code>(?=a + b + c)</code>; new expressions should prefer the direct form.</p>
2022
2022
<sectionclass="note">
2023
2023
<p><strong>String literals are ASCII-only.</strong> UTF-8 bytes in <code>'...'</code> will fail to compile. Non-ASCII text must come from the document via captures or string variables, or be placed in the literal portion of the replace string outside <code>(?=...)</code>. See <ahref="#exprtk-limitations">Limitations</a> below.</p>
<p>Built-in functions for converting between decimal and hexadecimal, binary, octal, or Roman numerals. Each base has a pair of functions: <code>numXXX</code>for <em>to-string</em> output,<code>XXXnum</code>for parsing back to a number.</p>
2103
+
<p>Built-in functions for parsing hexadecimal, binary, octal, or Roman numerals back to a number, plus Roman output. The decimal-to-hex/bin/oct <em>output</em> direction is handled by the format spec <code>~ x</code>/ <code>~ b</code> /<code>~ o</code>(see the Number formatting section), so there is no <code>num2hex</code>-style built-in.</p>
<li>Hex/bin/oct outputs are <strong>bare lowercase</strong> — no <code>0x</code> / <code>0b</code> / <code>0o</code> prefix. Compose prefixes if you want them: <code>(?='0x' + num2hex(num(1)))</code>.</li>
2138
+
<li>Hex/bin/oct output via <code>~ x</code> / <code>~ b</code> / <code>~ o</code> is <strong>bare lowercase</strong> — no <code>0x</code> / <code>0b</code> / <code>0o</code> prefix. Compose prefixes if you want them: <code>(?='0x' + num(1) ~ x)</code>.</li>
2154
2139
<li>Roman output is <strong>uppercase canonical</strong> form (subtractive pairs <code>IV</code>, <code>IX</code>, <code>XL</code>, etc.).</li>
2155
-
<li>Negative inputs to the bases produce <code>"-<digits>"</code> (e.g. <code>num2hex(-15)</code> → <code>"-f"</code>). For Roman, only the range 1..3999 is meaningful; out of range returns an empty string.</li>
2156
-
<li>Float inputs truncate toward zero (<code>num2hex(15.7) == num2hex(15)</code>).</li>
2140
+
<li>For Roman, only the range 1..3999 is meaningful; out of range returns an empty string.</li>
0 commit comments