Rename ieee_754_bit_representation functions

This commit is contained in:
Nigel Tao committed 2020-07-12 11:00:47 +10:00
1 parent b14e3eae9f
commit 4d449dc663
5 files changed
+65 -55

No files matched your search

+11 -7
View File
@@ -135,18 +135,22 @@ wuffs_base__parse_number_f64(wuffs_base__slice_u8 s, uint32_t options);
// --------
// wuffs_base__ieee_754_bit_representation__etc converts between a double
// precision numerical value and its IEEE 754 64-bit representation (1 sign
// bit, 11 exponent bits, 52 explicit significand bits).
// precision numerical value and its IEEE 754 representations:
// - 16-bit: 1 sign bit, 5 exponent bits, 10 explicit significand bits.
// - 32-bit: 1 sign bit, 8 exponent bits, 23 explicit significand bits.
// - 64-bit: 1 sign bit, 11 exponent bits, 52 explicit significand bits.
//
// For example, it converts between:
// - +1.0 and 0x3FF0_0000_0000_0000.
// - +5.5 and 0x4016_0000_0000_0000.
// - -inf and 0xFFF0_0000_0000_0000.
// - +1.0 and 0x3C00, 0x3F80_0000 or 0x3FF0_0000_0000_0000.
// - +5.5 and 0x4580, 0x40B0_0000 or 0x4016_0000_0000_0000.
// - -inf and 0xFC00, 0xFF80_0000 or 0xFFF0_0000_0000_0000.
//
// Converting from f64 to shorter formats may be lossy.
//
// See https://en.wikipedia.org/wiki/Double-precision_floating-point_format
static inline uint64_t //
wuffs_base__ieee_754_bit_representation__from_f64(double f) {
wuffs_base__ieee_754_bit_representation__from_f64_to_u64(double f) {
uint64_t u = 0;
if (sizeof(uint64_t) == sizeof(double)) {
memcpy(&u, &f, sizeof(uint64_t));
@@ -155,7 +159,7 @@ wuffs_base__ieee_754_bit_representation__from_f64(double f) {
}
static inline double //
wuffs_base__ieee_754_bit_representation__to_f64(uint64_t u) {
wuffs_base__ieee_754_bit_representation__from_u64_to_f64(uint64_t u) {
double f = 0;
if (sizeof(uint64_t) == sizeof(double)) {
memcpy(&f, &u, sizeof(uint64_t));