diff --git a/silleee.c b/silleee.c index 9819159..918174d 100644 --- a/silleee.c +++ b/silleee.c @@ -7,13 +7,13 @@ silleee silleee_sub(silleee x, silleee y) { silleee shift_and_round(int val, int bits) { static unsigned masks[24]= { - 0, 1, 3, 7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x7ff, 0xfff, 0x1fff, - 0x3fff, 0x7fff, 0xffff, 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, 0x1fffff, - 0x3fffff, 0x7fffff + 0, 1, 3, 7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff, 0x7ff, 0xfff, + 0x1fff, 0x3fff, 0x7fff, 0xffff, 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, + 0x1fffff, 0x3fffff, 0x7fffff }; static unsigned masks_ho[24] = { - 0, 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x8000, 0x1000, + 0, 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000 }; @@ -45,7 +45,7 @@ silleee silleee_add(silleee x, silleee y) { if (xexp == 127) { if (!xmant) { if (yexp == 127) { - if(!ymant) return xsign == ysign ? y : 0x7fc0000; + if(!ymant) return xsign == ysign ? y : 0x7fc00000; else return y; } } else { @@ -81,8 +81,8 @@ silleee silleee_add(silleee x, silleee y) { ++dexp; } else { if (dmant) { - while (dmant < sign_bit && dexp > -127) { - dmant = dmant << 1; + while (dmant < 0x800000 && dexp > -127) { + dmant <<= 1; --dexp; } } else {