Numerical and alphabetical suffixes: Difference between revisions

→‎{{header|Perl 6}}: implement scientific notation conversion at precision far beyond what the significant digits would suggest, tone down rhetoric
(Add Factor example)
(→‎{{header|Perl 6}}: implement scientific notation conversion at precision far beyond what the significant digits would suggest, tone down rhetoric)
Line 458:
=={{header|Perl 6}}==
{{works with|Rakudo|2018.09}}
Scientific notation, while supported in Perl 6, is limited to IEEE-754 64bit accuracy so there is some rounding on values using it. It would certainly be possible to implementImplements a custom "high accuracyprecision" 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.
 
Unfortunately, this suffix 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.
 
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
 
GOOGOLs 1e100> ~~ m:g/ ((<.:Lu>+) <.:Ll>*) \s+ (\S+) /;
<lang perl6>my $googol = 10**100;
<lang perl6><«PAIRs 2 SCOres 20 DOZens 12 GRoss 144 GREATGRoss 1728 GOOGOLs $googol»
GOOGOLs 1e100> ~~ m:g/ ((<.:Lu>+) <.:Ll>*) \s+ (\S+) /;
 
my %abr = |$/.map: {
Line 489 ⟶ 492:
my ($val, $unit, $fact) = $0, $1.Str.fc, $2.Str;
$val.=subst(',', '', :g);
if $val ~~ m:i/'e'/ {
my ($m,$e) = $val.split(/<[eE]>/);
$val = ($e < 0)
?? $m * FatRat.new(1,10**-$e)
!! $m * 10**$e;
}
my @suf = $unit;
unless %suffix{$unit}:exists {
Line 529 ⟶ 538:
25.123Mi: 26,343,374.848
2.5123e-00002Gi: 26,975,615.844352
+.25123E-7Ei: 28,964,846,960.237816237816578048
-.25123e-34Vikki: -33,394.1949381044419493810444147496234477542309678
2e-77gooGols: 199200,999000,999000,999000,999000,983000,222000,784000
9!: 362,880
9!!: 945
10,327

edits