X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/0e5d1f97871610a20d556c336b486e0b5a69a9e2..b2d1680d3a009d32f5e90f8dd693a5b0a6ca2435:/base.plp diff --git a/base.plp b/base.plp index f34f36e..7d31a4d 100644 --- a/base.plp +++ b/base.plp @@ -18,6 +18,26 @@ my @char = (0..9, 'A'..'Z', 'a'..'z'); :>

Number bases

+

Radix economy

+ +<: +sub radix_economy { + my ($val, $radix) = @_; + return $radix * int(log($val) / log($radix) + 1); +} + +use List::Util 'sum'; +print '
'; +print '', $_ for @morecols; +for my $max (100, 255, 1024) { + print '
', $max; + for my $radix (@morecols) { + printf '%.1f', + sum(map { radix_economy($_, $radix) } 1 .. $max) / $max; + } +} +:>
+

Fractions

<: