File: i2d.c

package info (click to toggle)
haskell-bytes 0.17.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 152 kB
  • sloc: haskell: 1,188; ansic: 33; makefile: 4
file content (37 lines) | stat: -rw-r--r-- 490 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdint.h>

uint64_t doubleToWord64(double input) {
  union {
    double d;
    uint64_t l;
  } u;
  u.d = input;
  return u.l;
}

double word64ToDouble(uint64_t input) {
  union {
    double d;
    uint64_t l;
  } u;
  u.l = input;
  return u.d;
}

uint32_t floatToWord32(float input) {
  union {
    float f;
    uint32_t l;
  } u;
  u.f = input;
  return u.l;
}

float word32ToFloat(uint32_t input) {
  union {
    float f;
    uint32_t l;
  } u;
  u.l = input;
  return u.f;
}