Html({
title => 'number bases',
- version => 'v1.1',
+ version => '1.1',
description => [
"Cheat sheets summarising various software programs and standards.",
],
});
my @cols = (2, 6, 8, 9, 10, 12, 16, 18, 20);
-my @morecols = (2, 3, 4, 6, 8, 9, 10, 12, 16, 18, 20, 24, 32, 36, 64);
+my @morecols = (2 .. 6, 8, 9, 10, 12, 16, 18, 20, 24, 32, 36, 64);
my @char = (0..9, 'A'..'Z', 'a'..'z');
:>
<h1>Number bases</h1>
-<h2>Fractions</h2>
+<h2>Radix economy</h2>
+<table>
+<:
+sub radix_economy {
+ my ($val, $radix) = @_;
+ return $radix * int(log($val) / log($radix) + 1);
+}
+
+use List::Util 'sum';
+print '<tr><th>';
+print '<th>', $_ for @morecols;
+for my $max (100, 255, 1024) {
+ print '<tr><th>⍳', $max;
+ for my $radix (@morecols) {
+ printf '<td style="text-align:right">%.1f',
+ sum(map { radix_economy($_, $radix) } 1 .. $max) / $max;
+ }
+}
+:></table>
+
+<h2>Reciprocal fractions (n⁻¹)</h2>
<table>
<:
print '<tr><th>';
<hr>
-<h2>Duplication</h2>
+<h2>Duplication (2ⁿ)</h2>
<table>
<:
use 5.010;