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() {
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
_ContVal_ |= FPUflagI | FPUflagSI;
_FdValf_ = sqrt( fabs( fpuDouble( _FtValUl_ ) ) );
}
else { _FdValf_ = sqrt( fpuDouble( _FtValUl_ ) ); } // If Ft is Positive
} else
_FdValf_ = sqrt( fpuDouble( _FtValUl_ ) ); // If Ft is Positive
clearFPUFlags( FPUflagD );
}