mirror of
https://github.com/QB64Official/qb64.git
synced 2024-09-04 11:10:15 +00:00
Update msbin.c
The processing for MKDMBF$ fails for numbers smaller than 1. Basic cause is the check for exponent overflow is incorrect. Changed code to correctly check for exponent overflow
This commit is contained in:
parent
c38716f3b7
commit
fb10bdb7f8
1 changed files with 8 additions and 5 deletions
|
@ -214,7 +214,7 @@ int32 _dieeetomsbin(double *src8, double *dest8)
|
||||||
/* Make a clobberable copy of the source number */
|
/* Make a clobberable copy of the source number */
|
||||||
memcpy(ieee,src8,8); //strncpy((char *)ieee,(char *)src8,8);
|
memcpy(ieee,src8,8); //strncpy((char *)ieee,(char *)src8,8);
|
||||||
|
|
||||||
for (i=0; i<8; i++) msbin[i] = 0;
|
memset(msbin, 0, sizeof(*dest8)); //for (i=0; i<8; i++) msbin[i] = 0;
|
||||||
|
|
||||||
/* If all are zero in src8, the msbin should be zero */
|
/* If all are zero in src8, the msbin should be zero */
|
||||||
for (i=0; i<8; i++) any_on |= ieee[i];
|
for (i=0; i<8; i++) any_on |= ieee[i];
|
||||||
|
@ -222,12 +222,15 @@ int32 _dieeetomsbin(double *src8, double *dest8)
|
||||||
|
|
||||||
sign = ieee[7] & 0x80;
|
sign = ieee[7] & 0x80;
|
||||||
msbin[6] |= sign;
|
msbin[6] |= sign;
|
||||||
msbin_exp = (unsigned)(ieee[7] & 0x7f) * 0x10;
|
msbin_exp = (unsigned)(ieee[7] & 0x7f) << 4; //(unsigned)(ieee[7] & 0x7f) * 0x10;
|
||||||
msbin_exp += ieee[6] >> 4;
|
msbin_exp += ieee[6] >> 4;
|
||||||
|
|
||||||
if (msbin_exp-0x3ff > 0x80) return 1;
|
// verify the exponent is in range for MBF encoding
|
||||||
|
msbin_exp = msbin_exp - 0x3ff + 0x80 + 1;
|
||||||
msbin[7] = msbin_exp - 0x3ff + 0x80 + 1;
|
if ((msbin_exp & 0xff00) != 0) return 1;
|
||||||
|
msbin[7] = msbin_exp;
|
||||||
|
// if (msbin_exp-0x3ff > 0x80) return 1;
|
||||||
|
// msbin[7] = msbin_exp - 0x3ff + 0x80 + 1;
|
||||||
|
|
||||||
/* The ieee mantissa must be shifted up 3 bits */
|
/* The ieee mantissa must be shifted up 3 bits */
|
||||||
ieee[6] &= 0x0f; /* mask out the exponent in the second byte */
|
ieee[6] &= 0x0f; /* mask out the exponent in the second byte */
|
||||||
|
|
Loading…
Reference in a new issue