From b23eba293df955c3772dd3eb2d91a8b1e4b8536f Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Wed, 8 Sep 2004 18:35:22 +0000 Subject: [PATCH] fixed 64 bit bugs with float-to-bool conversion and unary - operator --- plugins/include/float.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/include/float.inc b/plugins/include/float.inc index ca9b9dc2..c158e4a6 100755 --- a/plugins/include/float.inc +++ b/plugins/include/float.inc @@ -94,7 +94,7 @@ stock Float:operator--(Float:oper) return oper-1.0; stock Float:operator-(Float:oper) - return oper^Float:0x80000000; /* IEEE values are sign/magnitude */ + return oper^Float:((-1)^((-1)/2)); /* IEEE values are sign/magnitude */ stock Float:operator*(Float:oper1, oper2) return floatmul(oper1, float(oper2)); /* "*" is commutative */ @@ -163,8 +163,8 @@ stock bool:operator<=(oper1, Float:oper2) return floatcmp(float(oper1), oper2) <= 0; stock bool:operator!(Float:oper) - return (_:oper & 0x7fffffff) == 0; - + return (_:oper & ((-1)/2)) == 0; /* -1 = all bits to 1; /2 = remove most significant bit (sign) + works on both 32bit and 64bit systems; no constant required */ /* forbidden operations */ forward operator%(Float:oper1, Float:oper2); forward operator%(Float:oper1, oper2);