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 ;