math.constants: add single float epsilon value

db4
Slava Pestov 2009-09-03 02:23:22 -05:00
parent e3b967fe67
commit e86a76a7d8
2 changed files with 8 additions and 3 deletions

View File

@ -7,7 +7,8 @@ ARTICLE: "math-constants" "Constants"
{ $subsection euler }
{ $subsection phi }
{ $subsection pi }
{ $subsection epsilon } ;
{ $subsection epsilon }
{ $subsection single-epsilon } ;
ABOUT: "math-constants"
@ -25,4 +26,7 @@ HELP: pi
{ $values { "pi" "circumference of circle with diameter 1" } } ;
HELP: epsilon
{ $values { "epsilon" "smallest floating point value you can add to 1 without underflow" } } ;
{ $values { "epsilon" "smallest double-precision floating point value you can add to 1 without underflow" } } ;
HELP: single-epsilon
{ $values { "epsilon" "smallest single-precision floating point value you can add to 1 without underflow" } } ;

View File

@ -8,6 +8,7 @@ IN: math.constants
: phi ( -- phi ) 1.61803398874989484820 ; inline
: pi ( -- pi ) 3.14159265358979323846 ; inline
: 2pi ( -- pi ) 2 pi * ; inline
: epsilon ( -- epsilon ) 2.2204460492503131e-16 ; inline
: epsilon ( -- epsilon ) HEX: 3cb0000000000000 bits>double ; foldable
: single-epsilon ( -- epsilon ) HEX: 34000000 bits>float ; foldable
: smallest-float ( -- x ) HEX: 1 bits>double ; foldable
: largest-float ( -- x ) HEX: 7fefffffffffffff bits>double ; foldable