}
bool isnan(float e)
{
- float f = e;
- return (e != f);
+ // the sane way to detect NaN is broken because of a compiler bug
+ // (works with constants but breaks when assigned to variables)
+ // use conversion to string instead
+
+ //float f = e;
+ //return (e != f);
+ return ftos(e) == "-nan";
}
bool isnormal(float e)
{
float exp(float e)
{
- return (M_E ** e);
+ return pow(M_E, e);
}
float exp2(float e)
{
- return (2 ** e);
+ return pow(2, e);
}
float expm1(float e)
{
vector v;
v.z = 0;
v.y = ilogb(e) + 1;
- v.x = e / (2 ** v.y);
+ v.x = e / pow(2, v.y);
return v;
}
int ilogb(float e)
{
return floor(log2(fabs(e)));
}
-float ldexp(float e, int e)
+float ldexp(float x, int e)
{
- return e * (2 ** e);
+ return x * pow(2, e);
}
float logn(float e, float base)
{
float scalbn(float e, int n)
{
- return e * (2 ** n);
+ return e * pow(2, n);
}
float cbrt(float e)
{
- return copysign((fabs(e) ** (1.0/3.0)), e);
+ return copysign(pow(fabs(e), (1.0/3.0)), e);
}
float hypot(float e, float f)
{
{
return fabs(e) * ((f>0) ? 1 : -1);
}
+/// Always use `isnan` function to compare because `float x = nan(); x == x;` gives true
float nan(string tag)
{
return sqrt(-1);