blob: a65bd1b7858383c493c6f845b66cb0a13f64efb1 (
plain) (
blame)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#pragma once
#include "WAVM/Inline/BasicTypes.h"
namespace WAVM {
template<typename Float> struct FloatComponents;
// The components of a 64-bit float
template<> struct FloatComponents<F64>
{
typedef U64 Bits;
typedef F64 Float;
static constexpr I64 maxSignificand = 0xfffffffffffff;
static constexpr Uptr numSignificandBits = 52;
static constexpr Uptr numSignificandHexits = 13;
static constexpr I64 canonicalSignificand = 0x8000000000000ull;
static constexpr I64 denormalExponent = -1023;
static constexpr I64 minNormalExponent = -1022;
static constexpr I64 maxNormalExponent = 1023;
static constexpr I64 exponentBias = 1023;
static constexpr I64 maxExponentBits = 0x7ff;
union
{
struct
{
U64 significand : 52;
U64 exponent : 11;
U64 sign : 1;
} bits;
Float value;
Bits bitcastInt;
};
};
// The components of a 32-bit float.
template<> struct FloatComponents<F32>
{
typedef U32 Bits;
typedef F32 Float;
static constexpr I32 maxSignificand = 0x7fffff;
static constexpr Uptr numSignificandBits = 23;
static constexpr Uptr numSignificandHexits = 6;
static constexpr I32 canonicalSignificand = 0x400000;
static constexpr I32 denormalExponent = -127;
static constexpr I32 minNormalExponent = -126;
static constexpr I32 maxNormalExponent = 127;
static constexpr I32 exponentBias = 127;
static constexpr I32 maxExponentBits = 0xff;
union
{
struct
{
U32 significand : 23;
U32 exponent : 8;
U32 sign : 1;
} bits;
Float value;
Bits bitcastInt;
};
};
}
|