From e86a76a7d874ac80675e89c7f8fc3f14dc884ab7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 3 Sep 2009 02:23:22 -0500 Subject: [PATCH] math.constants: add single float epsilon value --- basis/math/constants/constants-docs.factor | 8 ++++++-- basis/math/constants/constants.factor | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/basis/math/constants/constants-docs.factor b/basis/math/constants/constants-docs.factor index 4fdd975202..117cd70c67 100644 --- a/basis/math/constants/constants-docs.factor +++ b/basis/math/constants/constants-docs.factor @@ -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" } } ; diff --git a/basis/math/constants/constants.factor b/basis/math/constants/constants.factor index a2d3213e78..cb81ded8ea 100644 --- a/basis/math/constants/constants.factor +++ b/basis/math/constants/constants.factor @@ -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