use math.bitwise here, add a couple tests

db4
Doug Coleman 2008-11-29 00:44:39 -06:00
parent 5b3e01f20a
commit 3e59cca630
2 changed files with 7 additions and 5 deletions

View File

@ -1,4 +1,7 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: tools.test math.floating-point ;
USING: tools.test math.floating-point math.constants kernel ;
IN: math.floating-point.tests
[ t ] [ pi >double< >double pi = ] unit-test
[ t ] [ -1.0 >double< >double -1.0 = ] unit-test

View File

@ -1,20 +1,20 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math sequences prettyprint math.parser io
math.functions ;
math.functions math.bitwise ;
IN: math.floating-point
: (double-sign) ( bits -- n ) -63 shift ; inline
: double-sign ( double -- n ) double>bits (double-sign) ;
: (double-exponent-bits) ( bits -- n )
-52 shift 11 2^ 1- bitand ; inline
-52 shift 11 on-bits mask ; inline
: double-exponent-bits ( double -- n )
double>bits (double-exponent-bits) ;
: (double-mantissa-bits) ( double -- n )
52 2^ 1- bitand ;
52 on-bits mask ;
: double-mantissa-bits ( double -- n )
double>bits (double-mantissa-bits) ;
@ -37,4 +37,3 @@ IN: math.floating-point
(double-mantissa-bits) >bin 52 CHAR: 0 pad-left
11 [ bl ] times print
] tri ;