mirror of
https://github.com/Russell-S-Harper/COMMON.git
synced 2024-11-24 08:30:57 +00:00
Merge pull request #10 from Russell-S-Harper/development
Rounding of _SET_V result.
This commit is contained in:
commit
a65e826f02
@ -6,10 +6,10 @@
|
|||||||
; to be able to recognize an overflow/underflow situation, rescale the arguments, and repeat the
|
; to be able to recognize an overflow/underflow situation, rescale the arguments, and repeat the
|
||||||
; calculation.
|
; calculation.
|
||||||
|
|
||||||
; Largest value: $3fffffff or 1048575.999(9)
|
; Largest value: $3fffffff or 1048575.999(5)
|
||||||
; Smallest value: $c0000001 or -1048575.999(0)
|
; Smallest value: $c0000001 or -1048575.998(5) <- note 998(5)
|
||||||
; Largest value for DEC/HEX: $3d08ffff or 999999.999(5)
|
; Largest value for DEC/HEX: $3d08ffff or 999999.999(5)
|
||||||
; Smallest value for DEC/HEX: $c2f70001 or -999999.999(0)
|
; Smallest value for DEC/HEX: $c2f70000 or -999999.999(5)
|
||||||
|
|
||||||
; Instructions
|
; Instructions
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ int main(int argc, char **argv)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
int j;
|
int j, sign;
|
||||||
unsigned long working;
|
unsigned long working;
|
||||||
const char *s = "", *p, *q;
|
const char *s = "", *p, *q;
|
||||||
switch (tokens[i].type)
|
switch (tokens[i].type)
|
||||||
@ -37,8 +37,14 @@ int main(int argc, char **argv)
|
|||||||
yyin = fmemopen((void *)p, q - p, "r");
|
yyin = fmemopen((void *)p, q - p, "r");
|
||||||
yyparse();
|
yyparse();
|
||||||
fclose(yyin);
|
fclose(yyin);
|
||||||
/* Output */
|
/* Round towards ± infinity */
|
||||||
|
sign = result < 0? -1: +1;
|
||||||
|
if (sign < 0) result = -result;
|
||||||
|
result += 1 << (INT_FRAC - EXP_FRAC - 1);
|
||||||
|
if (sign < 0) result = -result;
|
||||||
|
/* Normalize */
|
||||||
working = (unsigned long)((result >> (INT_FRAC - EXP_FRAC)) % (1 << EXP_FULL));
|
working = (unsigned long)((result >> (INT_FRAC - EXP_FRAC)) % (1 << EXP_FULL));
|
||||||
|
/* Output in .BYTE format */
|
||||||
for (j = 0; j < EXP_FULL; j += CHAR_BIT)
|
for (j = 0; j < EXP_FULL; j += CHAR_BIT)
|
||||||
{
|
{
|
||||||
printf("%s$%02lX", s, working & 0xff);
|
printf("%s$%02lX", s, working & 0xff);
|
||||||
|
Loading…
Reference in New Issue
Block a user