factor/library/math/float.factor

38 lines
791 B
Factor
Raw Normal View History

2006-01-28 15:49:31 -05:00
! Copyright (C) 2004, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2006-05-05 20:06:57 -04:00
IN: math-internals
USING: math kernel ;
2006-05-05 23:06:08 -04:00
: float= ( n n -- ? )
2006-05-05 20:06:57 -04:00
#! The compiler replaces this with a better intrinsic.
2006-05-05 23:06:08 -04:00
[ double>bits ] 2apply number= ; foldable
2006-05-05 20:06:57 -04:00
IN: math
UNION: real rational float ;
2005-09-16 22:47:28 -04:00
M: real abs dup 0 < [ neg ] when ;
M: real absq sq ;
M: real hashcode >fixnum ;
M: real <=> - ;
2006-01-28 15:49:31 -05:00
: fp-nan? ( float -- ? )
double>bits -51 shift BIN: 111111111111 [ bitand ] keep = ;
M: float zero?
2006-05-05 23:06:08 -04:00
dup 0.0 float= swap -0.0 float= or ;
2006-01-28 15:49:31 -05:00
M: float < float< ;
M: float <= float<= ;
M: float > float> ;
M: float >= float>= ;
2006-05-05 20:06:57 -04:00
M: float number= float= ;
M: float + float+ ;
M: float - float- ;
M: float * float* ;
M: float / float/f ;
M: float /f float/f ;
M: float mod float-mod ;