ksherlock / mpw

Macintosh Programmer's Workshop (mpw) compatibility layer
238 stars 21 forks source link

SC floating point constants #33

Open ksherlock opened 6 years ago

ksherlock commented 6 years ago
float f = 1.0f / 16.0f;
float ff = 0.0625f;

double d = 1.0 / 16.0;
double dd = 0.0625;

extended x = 1.0 / 16.0;
extended xx = 0.0625;

float generates an invalid value. double and extended are correct.

f:
$000000: 3F4E C4EC

ff:
$000000: 3FDC 0000   

d:
$000000: 3FB0 0000 0000 0000 

dd:
$000000: 3FB0 0000 0000 0000 

x:
$000000: 3FFB 8000 0000 0000 0000

xx:
$000000: 3FFB 8000 0000 0000 0000
ksherlock commented 6 years ago
a9ee DECSTR68K(0004)
     FCSTR2DEC(1.0, 0000, 00fff964, 00fff94a)
a9eb FP68K(0009)
     FDEC2X({  1 e0}, 00fff94a)
a9eb FP68K(080e)
     FD2X(00f527ae, 00fff9b6, 080e)
     1.968750  <<< s/b 1.0
a9eb FP68K(1010)
     FX2S(00fff9b6, 00fff9bc, 1010)
     1.968750
a9ee DECSTR68K(0004)
     FCSTR2DEC(16.0, 0000, 00fff84c, 00fff832)
a9eb FP68K(0009)
     FDEC2X({  16 e0}, 00fff832)
a9eb FP68K(080e)
     FD2X(00f527ae, 00fff89e, 080e)
     2.437500 <<<< s/b 16.0
a9eb FP68K(1010)
     FX2S(00fff89e, 00fff8a4, 1010)
     2.437500
ksherlock commented 6 years ago

behavior is identical in basilisk so I believe it is a bug in SC.

It seems to spuriously call FDEC2X for some reason.