summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-01-02 15:19:11 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-01-02 15:19:11 +0100
commit7e460c5ce1d7ddec4644eb930d6800317adbdf3d (patch)
tree0316b85b25ca84c433990ba42d85d86cd1b13bb0 /bin
parent462b6e74a7569208410985d182f1776ff564a89f (diff)
tibtoa: Added support for negative numbers
Diffstat (limited to 'bin')
-rwxr-xr-xbin/tibtoa10
1 files changed, 6 insertions, 4 deletions
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";