|
fixed_point128 1.0.1.0
128 bit integer, fixed point and floating point arithmetic for C++20
|
Bit level view of an IEEE 754 double-precision value. More...
#include <fp128_shared.h>
Public Member Functions | |
| constexpr | Double (double v=0) noexcept |
| Constructs from a double, or from positive zero when no value is given. | |
| constexpr uint64_t | f () const noexcept |
| Mantissa (fraction) bits. | |
| constexpr uint64_t | e () const noexcept |
| Biased exponent bits. | |
| constexpr uint64_t | s () const noexcept |
| Sign bit (0 = positive, 1 = negative). | |
| constexpr double | val () const noexcept |
| The double these bits encode. | |
| constexpr void | set_f (uint64_t v) noexcept |
| Sets the mantissa. Bits above the field width are dropped, as a bit-field assignment would. | |
| constexpr void | set_e (uint64_t v) noexcept |
| Sets the biased exponent. Bits above the field width are dropped. | |
| constexpr void | set_s (uint64_t v) noexcept |
| Sets the sign bit. | |
Static Public Member Functions | |
| static constexpr double | make (uint64_t s, uint64_t e, uint64_t f) noexcept |
| Assembles a double out of its three fields. | |
Public Attributes | |
| uint64_t | bits |
| The raw bit pattern of the double. | |
Bit level view of an IEEE 754 double-precision value.
Gives access to the mantissa, exponent and sign of a double without manual bit shifting, and assembles a double back out of those three fields.
The value is held as a raw bit pattern and converted with std::bit_cast rather than being overlaid with a union. The two produce identical code - a single move between register classes - but reading the inactive member of a union is not allowed during constant evaluation, which would keep every conversion between these types and a double out of a constant expression.
Definition at line 869 of file fp128_shared.h.
|
inlineconstexprnoexcept |
Constructs from a double, or from positive zero when no value is given.
Definition at line 873 of file fp128_shared.h.
|
inlinenodiscardconstexprnoexcept |
Mantissa (fraction) bits.
Definition at line 876 of file fp128_shared.h.
|
inlinenodiscardconstexprnoexcept |
Biased exponent bits.
Definition at line 878 of file fp128_shared.h.
|
inlinenodiscardconstexprnoexcept |
Sign bit (0 = positive, 1 = negative).
Definition at line 880 of file fp128_shared.h.
|
inlinenodiscardconstexprnoexcept |
The double these bits encode.
Definition at line 882 of file fp128_shared.h.
|
inlineconstexprnoexcept |
Sets the mantissa. Bits above the field width are dropped, as a bit-field assignment would.
Definition at line 885 of file fp128_shared.h.
|
inlineconstexprnoexcept |
Sets the biased exponent. Bits above the field width are dropped.
Definition at line 887 of file fp128_shared.h.
|
inlineconstexprnoexcept |
Sets the sign bit.
Definition at line 889 of file fp128_shared.h.
|
inlinestaticnodiscardconstexprnoexcept |
Assembles a double out of its three fields.
Preferred over three set_ calls wherever the value is built from scratch: those each mask the old field out before merging the new one, which is wasted work when there is nothing there yet.
| s | Sign bit. |
| e | Biased exponent. Bits above the field width are dropped. |
| f | Mantissa. Bits above the field width are dropped. |
Definition at line 903 of file fp128_shared.h.
| uint64_t fp128::Double::bits |
The raw bit pattern of the double.
Definition at line 870 of file fp128_shared.h.