diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-11-30 14:12:01 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-11-30 14:12:01 -0500 |
| commit | 4d8aa867c7f4661167a4742fbdd865ed2449503e (patch) | |
| tree | 67c9aeedaa3eb36585d1747e1f96e8c4708fc707 /api/integers.yaml | |
| parent | d302aaec38b9d295d39c4d87b53ee610bc9e0e07 (diff) | |
Add `base` parameter to integer parsing functions
Diffstat (limited to 'api/integers.yaml')
| -rw-r--r-- | api/integers.yaml | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/api/integers.yaml b/api/integers.yaml index 70709b04..b3c6b579 100644 --- a/api/integers.yaml +++ b/api/integers.yaml @@ -280,6 +280,15 @@ Int.parse: type: 'Text' description: > The text containing the integer. + base: + type: 'Int?' + default: 'none' + description: > + The numeric base to use when parsing the integer. If unspecified, the + integer's base will be inferred from the text prefix. After any "+" or + "-" sign, if the text begins with "0x", the base will be assumed to be + 16, "0o" will assume base 8, "0b" will assume base 2, otherwise the + base will be assumed to be 10. remainder: type: '&Text?' default: 'none' @@ -300,6 +309,9 @@ Int.parse: # Outside valid range: assert Int8.parse("9999999") == none + # Explicitly specifying base: + assert Int.parse("10", base=16) == 16 + Int.prev_prime: short: get the previous prime description: > |
