]> Shamusworld >> Repos - rmac/blobdiff - fltpoint.c
Version bump for last commit. :-)
[rmac] / fltpoint.c
index 2205a79f4c0d8d5a30d20216b8f08d17d84c7808..ffde55edc1ef6ea159663cde60440b7754bf813b 100644 (file)
@@ -189,7 +189,8 @@ uint32_t DoubleToDSPFloat(double d)
                return 0x800000;
        }
 
-       return trunc(round(ldexp(d, 23)));
+       // The casts are here because some compilers do weird shit.  See bug #149.
+       return (uint32_t)((int32_t)trunc(round(ldexp(d, 23))));
 }
 
 
@@ -209,7 +210,7 @@ uint64_t DoubleToFixedPoint(double d, int intBits, int fracBits)
 
        // Invert the result, if necessary
        if (signBit == 1)
-               result = (result = 0xFFFFFFFFFFFFFFFFLL) + 1;
+               result = (result ^ 0xFFFFFFFFFFFFFFFFLL) + 1;
 
        return result;
 }