summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
authorKent Quirk <q@lindenlab.com>2009-01-05 18:59:12 +0000
committerKent Quirk <q@lindenlab.com>2009-01-05 18:59:12 +0000
commit667ca55bad0108c4bdf8f007b89e1a52fc766aad (patch)
tree7bd62ac8d9af079c3994565f3f200ccc250bbc28 /indra/llmath
parent95f365789f4cebc7bd97ccefd538f14d481a8373 (diff)
svn merge -r106715:HEAD svn+ssh://svn.lindenlab.com/svn/linden/branches/q/notifications-merge-r106715 . QAR-1149 -- Final merge of notifications to trunk.
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/llmath.h24
-rw-r--r--indra/llmath/llrect.h5
2 files changed, 29 insertions, 0 deletions
diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h
index 0372bae106..916f4aa6c7 100644
--- a/indra/llmath/llmath.h
+++ b/indra/llmath/llmath.h
@@ -103,6 +103,30 @@ const F32 FP_MAG_THRESHOLD = 0.0000001f;
// TODO: Replace with logic like is_approx_equal
inline BOOL is_approx_zero( F32 f ) { return (-F_APPROXIMATELY_ZERO < f) && (f < F_APPROXIMATELY_ZERO); }
+// These functions work by interpreting sign+exp+mantissa as an unsigned
+// integer.
+// For example:
+// x = <sign>1 <exponent>00000010 <mantissa>00000000000000000000000
+// y = <sign>1 <exponent>00000001 <mantissa>11111111111111111111111
+//
+// interpreted as ints =
+// x = 10000001000000000000000000000000
+// y = 10000000111111111111111111111111
+// which is clearly a different of 1 in the least significant bit
+// Values with the same exponent can be trivially shown to work.
+//
+// WARNING: Denormals of opposite sign do not work
+// x = <sign>1 <exponent>00000000 <mantissa>00000000000000000000001
+// y = <sign>0 <exponent>00000000 <mantissa>00000000000000000000001
+// Although these values differ by 2 in the LSB, the sign bit makes
+// the int comparison fail.
+//
+// WARNING: NaNs can compare equal
+// There is no special treatment of exceptional values like NaNs
+//
+// WARNING: Infinity is comparable with F32_MAX and negative
+// infinity is comparable with F32_MIN
+
inline BOOL is_approx_equal(F32 x, F32 y)
{
const S32 COMPARE_MANTISSA_UP_TO_BIT = 0x02;
diff --git a/indra/llmath/llrect.h b/indra/llmath/llrect.h
index 21ca4189ff..93b69714de 100644
--- a/indra/llmath/llrect.h
+++ b/indra/llmath/llrect.h
@@ -223,6 +223,11 @@ public:
return *this;
}
+ bool isValid() const
+ {
+ return mLeft <= mRight && mBottom <= mTop;
+ }
+
bool isNull() const
{
return mLeft == mRight || mBottom == mTop;