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
|
|
|
|
2005-02-20 19:03:37 -05: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 ;
|
2005-02-20 19:03:37 -05:00
|
|
|
|
2006-08-15 03:01:24 -04:00
|
|
|
M: real hashcode >fixnum ;
|
2006-01-10 23:44:17 -05:00
|
|
|
M: real <=> - ;
|
2004-12-18 23:18:32 -05:00
|
|
|
|
2006-01-28 15:49:31 -05:00
|
|
|
: fp-nan? ( float -- ? )
|
|
|
|
double>bits -51 shift BIN: 111111111111 [ bitand ] keep = ;
|
|
|
|
|
2006-08-15 03:01:24 -04:00
|
|
|
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
|
|
|
|
2004-12-18 23:18:32 -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= ;
|
2004-12-18 23:18:32 -05:00
|
|
|
|
|
|
|
M: float + float+ ;
|
|
|
|
M: float - float- ;
|
|
|
|
M: float * float* ;
|
|
|
|
M: float / float/f ;
|
|
|
|
M: float /f float/f ;
|
2006-01-26 23:01:14 -05:00
|
|
|
M: float mod float-mod ;
|