1 #ifndef CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL
2 #error "Do not include binaryconversionprivate.h directly."
11 #pragma GCC diagnostic push
12 #pragma GCC diagnostic ignored "-Wsign-conversion"
20 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
21 return static_cast<std::int16_t
>((
static_cast<std::int16_t
>(value[0]) << 8 & 0xFF00) | (
static_cast<std::int16_t
>(value[1]) & 0x00FF));
23 return static_cast<std::int16_t
>((
static_cast<std::int16_t
>(value[1]) << 8 & 0xFF00) | (
static_cast<std::int16_t
>(value[0]) & 0x00FF));
32 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
33 return static_cast<std::uint16_t
>((
static_cast<std::uint16_t
>(value[0]) << 8 & 0xFF00) | (
static_cast<std::uint16_t
>(value[1]) & 0x00FF));
35 return static_cast<std::uint16_t
>((
static_cast<std::uint16_t
>(value[1]) << 8 & 0xFF00) | (
static_cast<std::uint16_t
>(value[0]) & 0x00FF));
44 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
45 return static_cast<std::int32_t
>((
static_cast<std::int32_t
>(value[0]) << 24 & 0xFF000000)
46 | (
static_cast<std::int32_t
>(value[1]) << 16 & 0x00FF0000) | (
static_cast<std::int32_t
>(value[2]) << 8 & 0x0000FF00)
47 | (
static_cast<std::int32_t
>(value[3]) & 0x000000FF));
49 return static_cast<std::int32_t
>((
static_cast<std::int32_t
>(value[3]) << 24 & 0xFF000000)
50 | (
static_cast<std::int32_t
>(value[2]) << 16 & 0x00FF0000) | (
static_cast<std::int32_t
>(value[1]) << 8 & 0x0000FF00)
51 | (
static_cast<std::int32_t
>(value[0]) & 0x000000FF));
60 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
61 return (
static_cast<std::uint32_t
>(value[0]) << 16 & 0x00FF0000) | (
static_cast<std::uint32_t
>(value[1]) << 8 & 0x0000FF00)
62 | (
static_cast<std::uint32_t
>(value[2]) & 0x000000FF);
64 return (
static_cast<std::uint32_t
>(value[2]) << 16 & 0x00FF0000) | (
static_cast<std::uint32_t
>(value[1]) << 8 & 0x0000FF00)
65 | (
static_cast<std::uint32_t
>(value[0]) & 0x000000FF);
74 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
75 return (
static_cast<std::uint32_t
>(value[0]) << 24 & 0xFF000000) | (
static_cast<std::uint32_t
>(value[1]) << 16 & 0x00FF0000)
76 | (
static_cast<std::uint32_t
>(value[2]) << 8 & 0x0000FF00) | (
static_cast<std::uint32_t
>(value[3]) & 0x000000FF);
78 return (
static_cast<std::uint32_t
>(value[3]) << 24 & 0xFF000000) | (
static_cast<std::uint32_t
>(value[2]) << 16 & 0x00FF0000)
79 | (
static_cast<std::uint32_t
>(value[1]) << 8 & 0x0000FF00) | (
static_cast<std::uint32_t
>(value[0]) & 0x000000FF);
88 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
89 return (
static_cast<std::int64_t
>(value[0]) << 56 & 0xFF00000000000000) | (
static_cast<std::int64_t
>(value[1]) << 48 & 0x00FF000000000000)
90 | (
static_cast<std::int64_t
>(value[2]) << 40 & 0x0000FF0000000000) | (
static_cast<std::int64_t
>(value[3]) << 32 & 0x000000FF00000000)
91 | (
static_cast<std::int64_t
>(value[4]) << 24 & 0x00000000FF000000) | (
static_cast<std::int64_t
>(value[5]) << 16 & 0x0000000000FF0000)
92 | (
static_cast<std::int64_t
>(value[6]) << 8 & 0x000000000000FF00) | (
static_cast<std::int64_t
>(value[7]) & 0x00000000000000FF);
94 return (
static_cast<std::int64_t
>(value[7]) << 56 & 0xFF00000000000000) | (
static_cast<std::int64_t
>(value[6]) << 48 & 0x00FF000000000000)
95 | (
static_cast<std::int64_t
>(value[5]) << 40 & 0x0000FF0000000000) | (
static_cast<std::int64_t
>(value[4]) << 32 & 0x000000FF00000000)
96 | (
static_cast<std::int64_t
>(value[3]) << 24 & 0x00000000FF000000) | (
static_cast<std::int64_t
>(value[2]) << 16 & 0x0000000000FF0000)
97 | (
static_cast<std::int64_t
>(value[1]) << 8 & 0x000000000000FF00) | (
static_cast<std::int64_t
>(value[0]) & 0x00000000000000FF);
106 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
107 return (
static_cast<std::uint64_t
>(value[0]) << 56 & 0xFF00000000000000) | (
static_cast<std::uint64_t
>(value[1]) << 48 & 0x00FF000000000000)
108 | (
static_cast<std::uint64_t
>(value[2]) << 40 & 0x0000FF0000000000) | (
static_cast<std::uint64_t
>(value[3]) << 32 & 0x000000FF00000000)
109 | (
static_cast<std::uint64_t
>(value[4]) << 24 & 0x00000000FF000000) | (
static_cast<std::uint64_t
>(value[5]) << 16 & 0x0000000000FF0000)
110 | (
static_cast<std::uint64_t
>(value[6]) << 8 & 0x000000000000FF00) | (
static_cast<std::uint64_t
>(value[7]) & 0x00000000000000FF);
112 return (
static_cast<std::uint64_t
>(value[7]) << 56 & 0xFF00000000000000) | (
static_cast<std::uint64_t
>(value[6]) << 48 & 0x00FF000000000000)
113 | (
static_cast<std::uint64_t
>(value[5]) << 40 & 0x0000FF0000000000) | (
static_cast<std::uint64_t
>(value[4]) << 32 & 0x000000FF00000000)
114 | (
static_cast<std::uint64_t
>(value[3]) << 24 & 0x00000000FF000000) | (
static_cast<std::uint64_t
>(value[2]) << 16 & 0x0000000000FF0000)
115 | (
static_cast<std::uint64_t
>(value[1]) << 8 & 0x000000000000FF00) | (
static_cast<std::uint64_t
>(value[0]) & 0x00000000000000FF);
124 const auto val = toInt32(value);
125 const auto *
const c =
reinterpret_cast<const char *
>(&val);
126 return *
reinterpret_cast<const float *
>(c);
134 const auto val = toInt64(value);
135 const auto *
const c =
reinterpret_cast<const char *
>(&val);
136 return *
reinterpret_cast<const double *
>(c);
144 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
145 outputbuffer[0] =
static_cast<char>((value >> 8) & 0xFF);
146 outputbuffer[1] =
static_cast<char>((value)&0xFF);
148 outputbuffer[1] =
static_cast<char>((value >> 8) & 0xFF);
149 outputbuffer[0] =
static_cast<char>((value)&0xFF);
158 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
159 outputbuffer[0] =
static_cast<char>((value >> 8) & 0xFF);
160 outputbuffer[1] =
static_cast<char>((value)&0xFF);
162 outputbuffer[1] =
static_cast<char>((value >> 8) & 0xFF);
163 outputbuffer[0] =
static_cast<char>((value)&0xFF);
173 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
174 outputbuffer[0] =
static_cast<char>((value >> 16) & 0xFF);
175 outputbuffer[1] =
static_cast<char>((value >> 8) & 0xFF);
176 outputbuffer[2] =
static_cast<char>((value)&0xFF);
178 outputbuffer[2] =
static_cast<char>((value >> 16) & 0xFF);
179 outputbuffer[1] =
static_cast<char>((value >> 8) & 0xFF);
180 outputbuffer[0] =
static_cast<char>((value)&0xFF);
189 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
190 outputbuffer[0] =
static_cast<char>((value >> 24) & 0xFF);
191 outputbuffer[1] =
static_cast<char>((value >> 16) & 0xFF);
192 outputbuffer[2] =
static_cast<char>((value >> 8) & 0xFF);
193 outputbuffer[3] =
static_cast<char>((value)&0xFF);
195 outputbuffer[3] =
static_cast<char>((value >> 24) & 0xFF);
196 outputbuffer[2] =
static_cast<char>((value >> 16) & 0xFF);
197 outputbuffer[1] =
static_cast<char>((value >> 8) & 0xFF);
198 outputbuffer[0] =
static_cast<char>((value)&0xFF);
207 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
208 outputbuffer[0] =
static_cast<char>((value >> 24) & 0xFF);
209 outputbuffer[1] =
static_cast<char>((value >> 16) & 0xFF);
210 outputbuffer[2] =
static_cast<char>((value >> 8) & 0xFF);
211 outputbuffer[3] =
static_cast<char>((value)&0xFF);
213 outputbuffer[3] =
static_cast<char>((value >> 24) & 0xFF);
214 outputbuffer[2] =
static_cast<char>((value >> 16) & 0xFF);
215 outputbuffer[1] =
static_cast<char>((value >> 8) & 0xFF);
216 outputbuffer[0] =
static_cast<char>((value)&0xFF);
225 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
226 outputbuffer[0] =
static_cast<char>((value >> 56) & 0xFF);
227 outputbuffer[1] =
static_cast<char>((value >> 48) & 0xFF);
228 outputbuffer[2] =
static_cast<char>((value >> 40) & 0xFF);
229 outputbuffer[3] =
static_cast<char>((value >> 32) & 0xFF);
230 outputbuffer[4] =
static_cast<char>((value >> 24) & 0xFF);
231 outputbuffer[5] =
static_cast<char>((value >> 16) & 0xFF);
232 outputbuffer[6] =
static_cast<char>((value >> 8) & 0xFF);
233 outputbuffer[7] =
static_cast<char>((value)&0xFF);
235 outputbuffer[7] =
static_cast<char>((value >> 56) & 0xFF);
236 outputbuffer[6] =
static_cast<char>((value >> 48) & 0xFF);
237 outputbuffer[5] =
static_cast<char>((value >> 40) & 0xFF);
238 outputbuffer[4] =
static_cast<char>((value >> 32) & 0xFF);
239 outputbuffer[3] =
static_cast<char>((value >> 24) & 0xFF);
240 outputbuffer[2] =
static_cast<char>((value >> 16) & 0xFF);
241 outputbuffer[1] =
static_cast<char>((value >> 8) & 0xFF);
242 outputbuffer[0] =
static_cast<char>((value)&0xFF);
251 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
252 outputbuffer[0] =
static_cast<char>((value >> 56) & 0xFF);
253 outputbuffer[1] =
static_cast<char>((value >> 48) & 0xFF);
254 outputbuffer[2] =
static_cast<char>((value >> 40) & 0xFF);
255 outputbuffer[3] =
static_cast<char>((value >> 32) & 0xFF);
256 outputbuffer[4] =
static_cast<char>((value >> 24) & 0xFF);
257 outputbuffer[5] =
static_cast<char>((value >> 16) & 0xFF);
258 outputbuffer[6] =
static_cast<char>((value >> 8) & 0xFF);
259 outputbuffer[7] =
static_cast<char>((value)&0xFF);
261 outputbuffer[7] =
static_cast<char>((value >> 56) & 0xFF);
262 outputbuffer[6] =
static_cast<char>((value >> 48) & 0xFF);
263 outputbuffer[5] =
static_cast<char>((value >> 40) & 0xFF);
264 outputbuffer[4] =
static_cast<char>((value >> 32) & 0xFF);
265 outputbuffer[3] =
static_cast<char>((value >> 24) & 0xFF);
266 outputbuffer[2] =
static_cast<char>((value >> 16) & 0xFF);
267 outputbuffer[1] =
static_cast<char>((value >> 8) & 0xFF);
268 outputbuffer[0] =
static_cast<char>((value)&0xFF);
277 auto *c =
reinterpret_cast<char *
>(&value);
278 auto i = *
reinterpret_cast<std::int32_t *
>(c);
279 getBytes(
i, outputbuffer);
287 auto *c =
reinterpret_cast<char *
>(&value);
288 auto i = *
reinterpret_cast<std::int64_t *
>(c);
289 getBytes(
i, outputbuffer);
293 #pragma GCC diagnostic pop
#define CPP_UTILITIES_EXPORT
Marks the symbol to be exported by the c++utilities library.
constexpr CPP_UTILITIES_EXPORT float toFloat32(std::uint16_t fixed8value)
Returns a 32-bit floating point number converted from the specified 8.8 fixed point representation.