summaryrefslogtreecommitdiff
path: root/test/data/parse/makefixed.pl
diff options
context:
space:
mode:
Diffstat (limited to 'test/data/parse/makefixed.pl')
-rwxr-xr-xtest/data/parse/makefixed.pl12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/data/parse/makefixed.pl b/test/data/parse/makefixed.pl
index 712784f..1a9306f 100755
--- a/test/data/parse/makefixed.pl
+++ b/test/data/parse/makefixed.pl
@@ -7,5 +7,15 @@ die "Usage: makefixed.pl <value>\n" if (@ARGV != 1);
my $val = shift @ARGV;
-printf("0x%.8x\n", $val * (1 << 10));
+$val *= (1 << 10);
+
+# Round away from zero
+if ($val < 0) {
+ $val -= 0.5;
+} else {
+ $val += 0.5;
+}
+
+# Truncates back towards zero
+printf("0x%.8x\n", $val);