diff options
author | Peter Johnson <peter@tortall.net> | 2001-10-03 07:12:46 +0000 |
---|---|---|
committer | Peter Johnson <peter@tortall.net> | 2001-10-03 07:12:46 +0000 |
commit | d3122122114d53f6cc26e74095dc1f6953df8e79 (patch) | |
tree | 7c39a635f8de31f882fff45ae7edf626405b0957 /libyasm/floatnum.c | |
parent | 055e7e2a3073d88aa871186f26d51be2355883b1 (diff) | |
download | yasm-d3122122114d53f6cc26e74095dc1f6953df8e79.tar.gz |
Implement floatnum_print() (for debugging purposes only).
svn path=/trunk/yasm/; revision=255
Diffstat (limited to 'libyasm/floatnum.c')
-rw-r--r-- | libyasm/floatnum.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/libyasm/floatnum.c b/libyasm/floatnum.c index 3fa8ff76..a0488c98 100644 --- a/libyasm/floatnum.c +++ b/libyasm/floatnum.c @@ -632,5 +632,30 @@ floatnum_get_extended(unsigned char *ptr, const floatnum *flt) void floatnum_print(const floatnum *flt) { - /* TODO */ + unsigned char out[10]; + unsigned char *str; + int i; + + /* Internal format */ + str = BitVector_to_Hex(flt->mantissa); + printf("%c %s *2^%04x\n", flt->sign?'-':'+', str, flt->exponent); + free(str); + + /* 32-bit (single precision) format */ + printf("32-bit: %d: ", floatnum_get_single(out, flt)); + for (i=0; i<4; i++) + printf("%02x ", out[i]); + printf("\n"); + + /* 64-bit (double precision) format */ + printf("64-bit: %d: ", floatnum_get_double(out, flt)); + for (i=0; i<8; i++) + printf("%02x ", out[i]); + printf("\n"); + + /* 80-bit (extended precision) format */ + printf("80-bit: %d: ", floatnum_get_extended(out, flt)); + for (i=0; i<10; i++) + printf("%02x ", out[i]); + printf("\n"); } |