Numeric separator syntax: Difference between revisions
Added Wren
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: Fix comment: Perl 6 --> Raku) |
(Added Wren) |
||
Line 508:
-321_00__0_
-321000
</pre>
=={{header|Wren}}==
{{libheader|Wren-fmt}}
Consistent with its C heritage, Wren doesn't support any form of separator in numeric literals.
However, it's possible using the Math-fmt module to add any single character 'thousands' separator when 'stringifying' an integer as the example below shows.
As currently written, this just supports separation of decimal integers into 3 digit groups from the right though it could be extended to deal with other scenarios as well.
<lang ecmascript>import "/fmt" for Fmt
var nums = [1e6, 1e9, 123456789, -123456789012]
var seps = [",", ".", " ", "*"]
for (i in 0...nums.count) System.print(Fmt.commatize(nums[i], seps[i]))</lang>
{{out}}
<pre>
1,000,000
1.000.000.000
123 456 789
-123*456*789*012
</pre>
|