2005-02-08 22:02:44 -05:00
|
|
|
! Copyright (C) 2004, 2005 Slava Pestov.
|
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
2005-12-13 17:33:58 -05:00
|
|
|
IN: kernel-internals
|
2006-05-05 21:41:57 -04:00
|
|
|
USING: kernel namespaces math ;
|
2005-12-13 17:33:58 -05:00
|
|
|
|
2006-01-26 23:01:14 -05:00
|
|
|
: bootstrap-cell \ cell get ; inline
|
2006-08-16 21:55:53 -04:00
|
|
|
: cells ( m -- n ) cell * ; inline
|
2006-01-26 23:01:14 -05:00
|
|
|
: bootstrap-cells bootstrap-cell * ; inline
|
|
|
|
|
2006-08-16 21:55:53 -04:00
|
|
|
: cell-bits ( -- n ) 8 cells ; inline
|
2006-03-19 20:28:07 -05:00
|
|
|
: bootstrap-cell-bits 8 bootstrap-cells ; inline
|
2005-12-13 17:33:58 -05:00
|
|
|
|
2006-05-05 21:41:57 -04:00
|
|
|
: tag-address ( x tag -- tagged ) swap tag-bits shift bitor ;
|
|
|
|
: tag-header ( id -- tagged ) object-tag tag-address ;
|
|
|
|
|
2004-09-07 23:47:18 -04:00
|
|
|
IN: math
|
|
|
|
|
2006-08-16 21:55:53 -04:00
|
|
|
: i ( -- i ) C{ 0 1 } ; inline
|
|
|
|
: -i ( -- -i ) C{ 0 -1 } ; inline
|
|
|
|
: e ( -- e ) 2.7182818284590452354 ; inline
|
|
|
|
: pi ( -- pi ) 3.14159265358979323846 ; inline
|
|
|
|
: epsilon ( -- epsilon ) 2.2204460492503131e-16 ; inline
|
|
|
|
|
|
|
|
: first-bignum ( -- n )
|
|
|
|
1 bootstrap-cell-bits tag-bits - 1- shift ;
|
|
|
|
|
|
|
|
: most-positive-fixnum ( -- n ) first-bignum 1- ;
|
|
|
|
: most-negative-fixnum ( -- n ) first-bignum neg ;
|