sub thead ($$) {
my ($t,$h) = @_;
- $$t = sprintf "%-10s |", $h;
+ $$t = sprintf "%-12s |", $h;
}
sub chead ($$) {
my ($t,$h) = @_;
}
sub theadend ($) {
my ($t) = @_;
- $$t .= "\n".('-'x(10+1)).'+'.('-'x(24*6))."\n";
+ $$t .= "\n".('-'x(12+1)).'+'.('-'x(24*6))."\n";
}
sub rhead ($$) {
my ($t,$h) = @_;
- $$t .= sprintf "%10s |", $h;
+ $$t .= sprintf "%12s |", $h;
}
sub cell ($$) {
my ($t,$v) = @_;
- $$t .= sprintf " %5.3f", $v;
+ $$t .= sprintf " %5s", $v;
}
sub rend ($$) {
my ($t,$n) = @_;
$$t .= "\n";
- $$t .= "\n" if ($n % 4) == 3;
+ $$t .= "\n" if (($n+1) % 6) == 0;
}
sub tend ($) {
my ($t) = @_;
}
+sub mul10fit ($$) {
+ my ($v,$len) = @_;
+ while (length(sprintf "%d", $v) < $len) { $v *= 10.0; }
+ return sprintf "%d", $v;
+}
+sub fracfit ($$) {
+ my ($v,$len) = @_;
+ $v= sprintf "%".($len+2).".${len}f", $v;
+ $v =~ s/^\d\.//;
+ return $v;
+}
+
sub scan () {
my ($row,$col,$lin,$log,$rownum);
@byrat = ();
- thead(\$tlin,'Row/Col');
- thead(\$tlog,'L(R/C)+1');
+ thead(\$tlin,'X/Y [*10^k]');
+ thead(\$tlog,'frac(L(X/Y))');
for $col (@e24) {
chead(\$tlin,$col);
chead(\$tlog,$col);
for $col (@e24) {
$lin= $col*1.0 / $row;
$log= log($lin)/log(10) + 1.0;
- cell(\$tlin,$lin);
- cell(\$tlog,$log);
+
+ cell(\$tlin, mul10fit($lin,5));
+ cell(\$tlog, fracfit($log,5));
+
if ($col < $row) { $lin *= 10; }
next if $row==$col;
push @byrat, { Num => $col,
sub byratcol ($$$) {
my ($or,$cwr,$colnum) = @_;
$$or .= ' ' if $colnum;
- $$cwr = ($colnum<4 ? 7 : 6);
+ $$cwr = ($colnum<6 ? 6 : 5);
}
sub printbyrat () {
use integer;
- my ($brcols) = 7;
+ my ($brcols) = 8;
my ($brrows) = (@byrat+$brcols-1) / $brcols;
my ($byrat,$o,$colnum,$rownum,$cw);
$o= '';
for ($colnum=0; $colnum<$brcols; $colnum++) {
byratcol(\$o,\$cw,$colnum);
- $o .= sprintf(" N/D %${cw}s %7s",
- 'Q[*10]','Lg(Q)+1');
+ $o .= sprintf("N/D %".($cw+1)."s %s",
+ 'Q*10^k','fc(Lg)');
}
$o .= "\n";
for ($colnum=0; $colnum<$brcols; $colnum++) {
byratcol(\$o,\$cw,$colnum);
- $o .= '-' x (5+1+$cw+1+7);
+ $o .= '-' x (5+1+$cw+1+5);
}
$o .= "\n";
for ($rownum=0; $rownum<$brrows; $rownum++) {
$byrat= $byrat[$colnum*$brrows + $rownum];
next unless defined $byrat;
byratcol(\$o,\$cw,$colnum);
- $o .= sprintf("%2s/%-2s %${cw}.".($cw-2)."f %7.5f",
+ $o .= sprintf("%2s/%-2s %${cw}s %s",
$byrat->{Num}, $byrat->{Den},
- $byrat->{Lin}, $byrat->{Log});
+ mul10fit($byrat->{Lin}, $cw),
+ fracfit($byrat->{Log}, 5));
}
$o .= "\n";
}
print $o or die $!;
}
+print "\n" or die $!;
scan();
ptable($tlin);
ptable($tlog);