Nearest FPU rounding mode now handles negative numbers correctly. Fixes Retro City Rampage 486.

This commit is contained in:
TomW 2015-09-26 17:54:25 +01:00
commit 299f6c8dfb
2 changed files with 12 additions and 3 deletions

View file

@ -2257,6 +2257,9 @@ static int32_t x87_fround32(double b)
switch ((npxc>>10)&3) switch ((npxc>>10)&3)
{ {
case 0: /*Nearest*/ case 0: /*Nearest*/
if (b < 0.0)
return (int32_t)(b-0.5);
else
return (int32_t)(b+0.5); return (int32_t)(b+0.5);
case 1: /*Down*/ case 1: /*Down*/
return (int32_t)floor(b); return (int32_t)floor(b);
@ -2271,6 +2274,9 @@ static int64_t x87_fround64(double b)
switch ((npxc>>10)&3) switch ((npxc>>10)&3)
{ {
case 0: /*Nearest*/ case 0: /*Nearest*/
if (b < 0.0)
return (int64_t)(b-0.5);
else
return (int64_t)(b+0.5); return (int64_t)(b+0.5);
case 1: /*Down*/ case 1: /*Down*/
return (int64_t)floor(b); return (int64_t)floor(b);

View file

@ -69,6 +69,9 @@ static inline int64_t x87_fround(double b)
switch ((npxc>>10)&3) switch ((npxc>>10)&3)
{ {
case 0: /*Nearest*/ case 0: /*Nearest*/
if (b < 0.0)
return (int64_t)(b-0.5);
else
return (int64_t)(b+0.5); return (int64_t)(b+0.5);
case 1: /*Down*/ case 1: /*Down*/
return (int64_t)floor(b); return (int64_t)floor(b);