diff options
author | 2015-03-03 21:18:46 +0200 | |
---|---|---|
committer | 2015-03-03 23:36:31 +0200 | |
commit | caf24072b0e4df7bf5baf05e1a301898f8f9906f (patch) | |
tree | 6b0740399362b2f4ab810958c43fd8eac9256bb8 /src/float | |
parent | 7577b64fe883d5b2e6f52f45e15b5a3575b8dac5 (diff) | |
download | librin-caf24072b0e4df7bf5baf05e1a301898f8f9906f.tar.gz librin-caf24072b0e4df7bf5baf05e1a301898f8f9906f.tar.bz2 librin-caf24072b0e4df7bf5baf05e1a301898f8f9906f.zip |
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.
Diffstat (limited to 'src/float')
-rw-r--r-- | src/float/float.c | 36 |
1 files changed, 36 insertions, 0 deletions
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; +} |