X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/0e5d1f97871610a20d556c336b486e0b5a69a9e2..31b12295df26f8c7b84422deca1a089278316965:/base.plp?ds=sidebyside diff --git a/base.plp b/base.plp index f34f36e..2deabf5 100644 --- a/base.plp +++ b/base.plp @@ -18,7 +18,27 @@ my @char = (0..9, 'A'..'Z', 'a'..'z'); :>

Number bases

-

Fractions

+

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; + } +} +:>
+ +

Reciprocal fractions (n⁻¹)

<: print '
'; @@ -74,7 +94,7 @@ for my $n (2 .. $count) {
-

Duplication

+

Duplication (2ⁿ)

<: use 5.010;