RMW desert 1.0
Loading...
Searching...
No Matches
ieee754.h
1/*
2 * SPDX-FileCopyrightText: 2021 Kyunghwan Kwon <k@mononn.com>
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#ifndef CBOR_IEEE754_H
8#define CBOR_IEEE754_H
9
10#if defined(__cplusplus)
11extern "C" {
12#endif
13
14#include <stdint.h>
15#include <stdbool.h>
16
17typedef union {
18 uint16_t value;
19 struct {
20 uint32_t m: 10;
21 uint32_t e: 5;
22 uint32_t sign: 1;
23 } components;
25
26typedef union {
27 float value;
28 struct {
29 uint32_t m: 23;
30 uint32_t e: 8;
31 uint32_t sign: 1;
32 } components;
34
35typedef union {
36 double value;
37 struct {
38 uint64_t m: 52;
39 uint64_t e: 11;
40 uint64_t sign: 1;
41 } components;
43
44uint16_t ieee754_convert_single_to_half(float value);
45double ieee754_convert_half_to_double(uint16_t value);
46
47bool ieee754_is_shrinkable_to_half(float value);
48bool ieee754_is_shrinkable_to_single(double value);
49
50#if defined(__cplusplus)
51}
52#endif
53
54#endif /* CBOR_IEEE754_H */
Definition ieee754.h:35
Definition ieee754.h:17
Definition ieee754.h:26