From 12fd01346d92d24f9e6ecd89c57e25cdaa455e12 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sun, 12 Feb 2017 10:05:58 -0500 Subject: remove float16 to float32 conversion --- tools/ootx_decode/ootx_decoder.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) (limited to 'tools') diff --git a/tools/ootx_decode/ootx_decoder.c b/tools/ootx_decode/ootx_decoder.c index 6c5031c..fb87e41 100644 --- a/tools/ootx_decode/ootx_decoder.c +++ b/tools/ootx_decode/ootx_decoder.c @@ -252,36 +252,8 @@ uint8_t* get_ptr(uint8_t* data, uint8_t bytes, uint16_t* idx) { } float _to_float(uint8_t* data) { - uint16_t h = *(uint16_t*)(data); - uint16_t h_exp, h_sig; - uint32_t f_sgn, f_exp, f_sig; - - h_exp = (h&0x7c00u); - f_sgn = ((uint32_t)h&0x8000u) << 16; - if (h_exp == 0x0000u) { /* 0 or subnormal */ - h_sig = (h&0x03ffu); - /* Signed zero */ - if (h_sig == 0) { - return f_sgn; - } - /* Subnormal */ - h_sig <<= 1; - while ((h_sig&0x0400u) == 0) { - h_sig <<= 1; - h_exp++; - } - f_exp = ((uint32_t)(127 - 15 - h_exp)) << 23; - f_sig = ((uint32_t)(h_sig&0x03ffu)) << 13; - return f_sgn + f_exp + f_sig; - } - else if (h_exp == 0x7c00u) { /* inf or NaN */ - /* All-ones exponent and a copy of the significand */ - return f_sgn + 0x7f800000u + (((uint32_t)(h&0x03ffu)) << 13); - } - else { /* normalized */ - /* Just need to adjust the exponent and shift */ - return f_sgn + (((uint32_t)(h&0x7fffu) + 0x1c000u) << 13); - } + uint16_t x = *(uint16_t*)data; + return x; } void init_lighthouse_info_v6(lighthouse_info_v6* lhi, uint8_t* data) { -- cgit v1.2.3