Prevent truncation in maxDoubleForInteger
Bug: http://b/27512382
Use uint64_t instead of 'unsigned long' as the latter's size may not
always be 64-bits. Doing so makes maxDoubleForInteger return the
expected result.
Change-Id: I1db0af0e11ff55a99994b6b81a9cb5d18d525e7c
diff --git a/api/Utilities.cpp b/api/Utilities.cpp
index 6218d51..fa9fd36 100644
--- a/api/Utilities.cpp
+++ b/api/Utilities.cpp
@@ -145,8 +145,8 @@
* to create smaller values to avoid a round up. Same for floats and halfs.
*/
int lowZeroBits = max(0, numberOfIntegerBits - mantissaSize);
- unsigned long l = (0xffffffffffffffff >> (64 - numberOfIntegerBits + lowZeroBits))
- << lowZeroBits;
+ uint64_t l = (0xffffffffffffffff >> (64 - numberOfIntegerBits + lowZeroBits))
+ << lowZeroBits;
return (double)l;
}