View Single Post
Old 25 July 2021, 17:11   #12
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,243
Quote:
Originally Posted by phx View Post
Ok, so we have either rounding issues by the round-to-zero policy, or we have rounding issues when using mathieeesingbas and mathieeedoubbas in parallel. Sigh.
I afraid this all boils down to a design issue of the 68881/882, namely that it performs double rounding. If you can get away with non-iEEE aware round-to-nearest in some rare cases, the only option I can give you is to open mathieeesingbas first, then doubbas. This way, rounding in double precision will be correct, though computation in single precision will be rounded twice (i.e. first to double, and when storing to memory, to single again).


The latter is not exactly correct, and may in some corner cases result in incorrect rounding, but it is quite exceptional.


For the 68040 and onwards, this problem does not exist. The math libraries then use the dedicated single/double precision instructions that intrinsically round to the right precision. Even in that case opening singbas first and doubbas later will work, but will always give the right (IEEE aware rounded) results.


Anyhow, there is really no good solution. Either round to zero all the way, or switch the precision on each call, or accept some mis-rounded results with the 68881/882. Currently, my choice is the latter.
Thomas Richter is offline  
 
Page generated in 0.05831 seconds with 11 queries