From 7e460c5ce1d7ddec4644eb930d6800317adbdf3d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 2 Jan 2009 15:19:11 +0100 Subject: tibtoa: Added support for negative numbers --- bin/tibtoa | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/tibtoa b/bin/tibtoa index b66cb46..ed71f93 100755 --- a/bin/tibtoa +++ b/bin/tibtoa @@ -782,14 +782,16 @@ if ($header{type} eq 'program') { while ($offset+9 <= $length) { $i++; $digit = ''; - $exp = ord(substr($program, ++$offset, 1)) - 128; + if (ord(substr($program, $offset++, 1)) >= 0x80) { + $digit .= '-'; + } + $exp = ord(substr($program, $offset++, 1)) - 128; for(1 .. 7) { - $char = ord(substr($program, ++$offset, 1)); + $char = ord(substr($program, $offset++, 1)); $digit .= $char >> 4; $digit .= $char & 0x0f; } - $offset++; - substr($digit, 1, 0, '.'); + substr($digit, 1 + ($digit <= 0), 0, '.'); printf('%-8s', $digit * (10 ** $exp)); if ($header{type} eq 'matrix' and $i == $header{size}->{cols} or $header{type} eq 'var') { print "\n"; -- cgit v1.2.3