Numerical and alphabetical suffixes: Difference between revisions

→‎{{header|Perl 6}}: Commentary on output format requirements
m (→‎{{header|Perl 6}}: fat fingered the IEEE standard)
(→‎{{header|Perl 6}}: Commentary on output format requirements)
Line 138:
=={{header|Perl 6}}==
{{works with|Rakudo|2018.09}}
Scientific notation, while supported in Perl 6, is limited to IEEIEEE-754 64bit accuracy so there is some rounding on values using it. It would certainly be possible to implement a custom high accuracy conversion routine but I can't really see the point since unfortunately, this routine is of limited use for practical everyday purposes. It focuses on handling excessively large and archaic units (googol, greatgross) and completely ignores or makes unusable (due to forcing case insensitivity) many common current ones: c(centi), m(milli), μ(micro). Ah well.
 
Note: I am blatantly and deliberately ignoring the pointless & silly task guidelines for formatting the output. It's fluff and has no bearing on the core of the task. If you really, ''really'','' '''REALLY''' ''want to see badly formatted, stupid output, uncomment the last line.
 
<lang perl6><PAIRs 2 SCOres 20 DOZens 12 GRoss 144 GREATGRoss 1728
Line 178 ⟶ 180:
}
 
my $tests = q:to '===';
printf "%16s: %s\n", $_, comma .&units for <
2greatGRo 24Gros 288Doz 1,728pairs 172.8SCOre
1,567 +1.567k 0.1567e-2m
25.123kK 25.123m 2.5123e-00002G
25.123kiKI 25.123Mi 2.5123e-00002Gi +.25123E-7Ei
-.25123e-34Vikki 2e-77gooGols
9! 9!! 9!!! 9!!!! 9!!!!! 9!!!!!! 9!!!!!!! 9!!!!!!!! 9!!!!!!!!!
.017k!!
===
>;</lang>
 
printf "%16s: %s\n", $_, comma .&units for <$test.words;
 
# Task required stupid layout
# say "\n In: $_\nOut : ", .words.map({comma .&units}).join(' ') for $test.lines;</lang>
{{out}}
<pre> 2greatGRo: 3,456
10,333

edits