From caf24072b0e4df7bf5baf05e1a301898f8f9906f Mon Sep 17 00:00:00 2001 From: Gediminas Jakutis Date: Tue, 3 Mar 2015 21:18:46 +0200 Subject: float: add [integer types] -> [float types] conversion functions. These were forgotten previously and only [float types] -> [integer types] functions were present. This commit adds the missing "reverse" functions. --- src/float/float.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/float/float.c') diff --git a/src/float/float.c b/src/float/float.c index 9520bea..e9e6700 100644 --- a/src/float/float.c +++ b/src/float/float.c @@ -229,6 +229,24 @@ int32_t rin_float_to_int(const float num) return ret; } +float rin_uint_to_float(const uint32_t num) +{ + float ret; + + memcpy(&ret, &num, sizeof(num)); + + return ret; +} + +float rin_int_to_float(const int32_t num) +{ + float ret; + + memcpy(&ret, &num, sizeof(num)); + + return ret; +} + uint64_t rin_double_to_ulong(const double num) { uint64_t ret; @@ -246,3 +264,21 @@ int64_t rin_double_to_long(const double num) return ret; } + +double rin_ulong_to_double(const uint64_t num) +{ + double ret; + + memcpy(&ret, &num, sizeof(num)); + + return ret; +} + +double rin_long_to_double(const int64_t num) +{ + double ret; + + memcpy(&ret, &num, sizeof(num)); + + return ret; +} -- cgit v1.2.3