diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2009-01-02 15:19:11 +0100 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2009-01-02 15:19:11 +0100 |
commit | 7e460c5ce1d7ddec4644eb930d6800317adbdf3d (patch) | |
tree | 0316b85b25ca84c433990ba42d85d86cd1b13bb0 /bin | |
parent | 462b6e74a7569208410985d182f1776ff564a89f (diff) |
tibtoa: Added support for negative numbers
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/tibtoa | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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"; |