use math.bitwise here, add a couple tests
parent
5b3e01f20a
commit
3e59cca630
|
@ -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
|
||||
|
|
|
@ -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 ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue