From f459c24e454057aa921bbb5cef4799a442149d69 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 20 Sep 2009 16:48:42 -0500 Subject: [PATCH] oops, float>hex didn't preserve leading zeroes in mantissa --- core/math/parser/parser-tests.factor | 3 +++ core/math/parser/parser.factor | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/math/parser/parser-tests.factor b/core/math/parser/parser-tests.factor index f2ccb78a06..34bca8a34e 100644 --- a/core/math/parser/parser-tests.factor +++ b/core/math/parser/parser-tests.factor @@ -129,6 +129,7 @@ unit-test [ "1.0p0" ] [ 1.0 >hex ] unit-test [ "1.8p2" ] [ 6.0 >hex ] unit-test +[ "1.08p2" ] [ 4.125 >hex ] unit-test [ "1.8p-2" ] [ 0.375 >hex ] unit-test [ "-1.8p2" ] [ -6.0 >hex ] unit-test [ "1.8p10" ] [ 1536.0 >hex ] unit-test @@ -137,6 +138,8 @@ unit-test [ "-0.0" ] [ -0.0 >hex ] unit-test [ 1.0 ] [ "1.0" hex> ] unit-test +[ 1.5 ] [ "1.8" hex> ] unit-test +[ 1.03125 ] [ "1.08" hex> ] unit-test [ 15.5 ] [ "f.8" hex> ] unit-test [ 15.53125 ] [ "f.88" hex> ] unit-test [ -15.5 ] [ "-f.8" hex> ] unit-test diff --git a/core/math/parser/parser.factor b/core/math/parser/parser.factor index d422a2c199..a53604ddf9 100644 --- a/core/math/parser/parser.factor +++ b/core/math/parser/parser.factor @@ -213,7 +213,8 @@ M: ratio >base -0.0 double>bits bitand zero? "" "-" ? ; : float>hex-value ( mantissa -- str ) - 16 >base [ CHAR: 0 = ] trim-tail [ "0" ] [ ] if-empty "1." prepend ; + 16 >base 13 CHAR: 0 pad-head [ CHAR: 0 = ] trim-tail + [ "0" ] [ ] if-empty "1." prepend ; : float>hex-expt ( mantissa -- str ) 10 >base "p" prepend ;