[nexuiz-commits] r8248 - trunk/data/qcsrc/common

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Nov 8 12:43:37 EST 2009


Author: div0
Date: 2009-11-08 12:43:37 -0500 (Sun, 08 Nov 2009)
New Revision: 8248

Modified:
   trunk/data/qcsrc/common/mathlib.qc
Log:
fix some mathlib bugs


Modified: trunk/data/qcsrc/common/mathlib.qc
===================================================================
--- trunk/data/qcsrc/common/mathlib.qc	2009-11-08 17:40:59 UTC (rev 8247)
+++ trunk/data/qcsrc/common/mathlib.qc	2009-11-08 17:43:37 UTC (rev 8248)
@@ -93,13 +93,13 @@
 {
 	vector v;
 	v_z = 0;
-	v_y = ilogb(x);
+	v_y = ilogb(x) + 1;
 	v_x = x / exp2(v_y);
 	return v;
 }
 int ilogb(float x)
 {
-	return floor(log2(x));
+	return floor(log2(fabs(x)));
 }
 float ldexp(float x, int e)
 {
@@ -144,7 +144,7 @@
 }
 float logb(float x)
 {
-	return floor(log2(x));
+	return floor(log2(fabs(x)));
 }
 vector modf(float f)
 {
@@ -179,6 +179,8 @@
 vector lgamma(float x)
 {
 	// TODO improve accuracy
+	if(!isfinite(x))
+		return fabs(x);
 	if(x < 1 && x == floor(x))
 		return nan("gamma") * '1 1 1';
 	if(x < 0.1)



More information about the nexuiz-commits mailing list