mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-24 22:24:31 +00:00
missed one error with clang
This commit is contained in:
@@ -36,7 +36,20 @@ double Math::random()
|
||||
//the value of the argument rounded to the nearest long value.
|
||||
__int64 Math::round( double d )
|
||||
{
|
||||
return (__int64)floor( d + 0.5 );
|
||||
// 4jcraft fixes the fact that if double is a huge
|
||||
// number than the cast of d to int64_t overflows
|
||||
|
||||
d = floor( d + 0.5 );
|
||||
|
||||
// if smaller or bigger than representable int64 than return the max
|
||||
if(d >= (double)INT64_MAX) {
|
||||
return INT64_MAX;
|
||||
|
||||
} else if (d <= (double)INT64_MIN) {
|
||||
return INT64_MIN;
|
||||
}
|
||||
|
||||
return (int64_t) d;
|
||||
}
|
||||
|
||||
int Math::_max(int a, int b)
|
||||
@@ -73,4 +86,4 @@ double Math::wrapDegrees(double input)
|
||||
if (input >= 180.0) input -= 360.0;
|
||||
if (input < -180.0) input += 360.0;
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user