aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath/llmath.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:56 -0500
committerJacek Antonelli2008-08-15 23:44:56 -0500
commitc07901e29ed545bbb02e3bddf148fe1104b94e9f (patch)
treef1ada64ce834acd7d92a425efb96c4b86bcf16b1 /linden/indra/llmath/llmath.h
parentSecond Life viewer sources 1.15.0.2 (diff)
downloadmeta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.zip
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.gz
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.bz2
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.xz
Second Life viewer sources 1.15.1.3
Diffstat (limited to 'linden/indra/llmath/llmath.h')
-rw-r--r--linden/indra/llmath/llmath.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/linden/indra/llmath/llmath.h b/linden/indra/llmath/llmath.h
index dbd825d..dd44e0c 100644
--- a/linden/indra/llmath/llmath.h
+++ b/linden/indra/llmath/llmath.h
@@ -99,6 +99,27 @@ inline BOOL is_approx_equal(F32 x, F32 y)
99 return (abs((S32) ((U32&)x - (U32&)y) ) < COMPARE_MANTISSA_UP_TO_BIT); 99 return (abs((S32) ((U32&)x - (U32&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);
100} 100}
101 101
102inline BOOL is_approx_equal_fraction(F32 x, F32 y, U32 frac_bits)
103{
104 BOOL ret = TRUE;
105 F32 diff = (F32) fabs(x - y);
106
107 S32 diffInt = (S32) diff;
108 S32 diffFracTolerance = (S32) ((diff - (F32) diffInt) * (1 << frac_bits));
109
110 // if integer portion is not equal, not enough bits were used for packing
111 // so error out since either the use case is not correct OR there is
112 // an issue with pack/unpack. should fail in either case.
113 // for decimal portion, make sure that the delta is no more than 1
114 // based on the number of bits used for packing decimal portion.
115 if (diffInt != 0 || diffFracTolerance > 1)
116 {
117 ret = FALSE;
118 }
119
120 return ret;
121}
122
102inline S32 llabs(const S32 a) 123inline S32 llabs(const S32 a)
103{ 124{
104 return S32(labs(a)); 125 return S32(labs(a));