math.parser: fix "most-negative-fixnum number>string string>number fixnum?".

db4
John Benediktsson 2015-07-14 20:03:33 -07:00
parent 154ebac5af
commit 866b40271d
2 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,5 @@
USING: kernel literals math math.parser sequences tools.test ; USING: kernel layouts literals math math.parser sequences
tools.test ;
IN: math.parser.tests IN: math.parser.tests
{ f } { f }
@ -359,3 +360,6 @@ unit-test
{ f } [ "0b0" bin> ] unit-test { f } [ "0b0" bin> ] unit-test
{ f } [ "0o0" bin> ] unit-test { f } [ "0o0" bin> ] unit-test
{ f } [ "0x0" bin> ] unit-test { f } [ "0x0" bin> ] unit-test
{ t } [ most-positive-fixnum number>string string>number fixnum? ] unit-test
{ t } [ most-negative-fixnum number>string string>number fixnum? ] unit-test

View File

@ -98,7 +98,12 @@ TUPLE: float-parse
} cond ; } cond ;
: ?neg ( n/f -- -n/f ) : ?neg ( n/f -- -n/f )
[ neg ] [ f ] if* ; inline [
dup bignum? [
dup first-bignum bignum=
[ drop most-negative-fixnum ] [ neg ] if
] [ neg ] if
] [ f ] if* ; inline
: ?add-ratio ( m n/f -- m+n/f ) : ?add-ratio ( m n/f -- m+n/f )
dup ratio? [ + ] [ 2drop f ] if ; inline dup ratio? [ + ] [ 2drop f ] if ; inline