u64ToDouble(u64 value)
{
double r;
- u64 tmp = value & 0x7fffffffffffffff;
+ u64 tmp = value & u64Const(0x7fffffffffffffff);
r = (double)(s64)tmp;
- if (value & 0x8000000000000000)
+ if (value & u64Const(0x8000000000000000))
r += 9.2233720368547758080e18; /* 2^63 */
return r;
}
* This is for MS Visual Studio
*/
#ifdef _MSC_VER
- #define u64 unsigned __int64
+ #define u64 unsigned __int64
#define s64 signed __int64
- #define u64Display "%I64u"
+ #define u64Display "%I64u"
+ #define s64Display "%I64d"
+ #define u64Const(c) (c ## UI64)
+ #define s64Const(c) (c ## I64)
#else
/* place holder
* or dummy types for other compiler
*/
- #define u64 unsigned __int64
+ #define u64 unsigned __int64
#define s64 signed __int64
- #define u64Display "%I64u"
+ #define u64Display "%I64u"
+ #define s64Display "%I64d"
+ #define u64Const(c) (c ## UI64)
+ #define s64Const(c) (c ## I64)
#endif
#else
/* GNU gcc */
- #define u64 unsigned long long
+ #define u64 unsigned long long
#define s64 signed long long
- #define u64Display "%llu"
+ #define u64Display "%llu"
+ #define s64Display "%lld"
+ #define u64Const(c) (c ## ull)
+ #define s64Const(c) (c ## ll)
#endif