From d3122122114d53f6cc26e74095dc1f6953df8e79 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 3 Oct 2001 07:12:46 +0000 Subject: [PATCH] Implement floatnum_print() (for debugging purposes only). svn path=/trunk/yasm/; revision=255 --- libyasm/floatnum.c | 27 ++++++++++++++++++++++++++- src/floatnum.c | 27 ++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 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"); } diff --git a/src/floatnum.c b/src/floatnum.c index 3fa8ff76..a0488c98 100644 --- a/src/floatnum.c +++ b/src/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"); } -- 2.40.0