FPU: sqrt(-0) == 0

It is marked as a special case in the doc (sqrt(-0) == -0)
but test on the PS2 show the contrary. Quite a mistery
This commit is contained in:
Gregory Hainaut 2016-01-30 16:30:18 +01:00
parent 6391b00c00
commit 3ec458ef4f
1 changed files with 4 additions and 3 deletions

View File

@ -345,12 +345,13 @@ void RSQRT_S() {
} }
void SQRT_S() { void SQRT_S() {
if ( ( _FtValUl_ & 0xFF800000 ) == 0x80000000 ) { _FdValUl_ = 0x80000000; } // If Ft = -0 if ( ( _FtValUl_ & 0x7F800000 ) == 0 ) // If Ft = +/-0
_FdValUl_ = 0;// result is 0
else if ( _FtValUl_ & 0x80000000 ) { // If Ft is Negative else if ( _FtValUl_ & 0x80000000 ) { // If Ft is Negative
_ContVal_ |= FPUflagI | FPUflagSI; _ContVal_ |= FPUflagI | FPUflagSI;
_FdValf_ = sqrt( fabs( fpuDouble( _FtValUl_ ) ) ); _FdValf_ = sqrt( fabs( fpuDouble( _FtValUl_ ) ) );
} } else
else { _FdValf_ = sqrt( fpuDouble( _FtValUl_ ) ); } // If Ft is Positive _FdValf_ = sqrt( fpuDouble( _FtValUl_ ) ); // If Ft is Positive
clearFPUFlags( FPUflagD ); clearFPUFlags( FPUflagD );
} }