ConfigDB::const_number_t Struct Reference
Compile-time constant number. More...
#include <Number.h>
Inheritance diagram for ConfigDB::const_number_t:
Collaboration diagram for ConfigDB::const_number_t:
Public Member Functions | |
| const_number_t ()=default | |
| constexpr | const_number_t (double value) |
| Computer number from a compile-time constant value. More... | |
Public Member Functions inherited from ConfigDB::number_t | |
| bool | operator== (const number_t &other) const |
| bool | operator!= (const number_t &other) const |
| bool | sign () const |
| bool | operator< (const number_t &other) const |
| bool | operator> (const number_t &other) const |
| size_t | printTo (Print &p) const |
Additional Inherited Members | |
Static Public Member Functions inherited from ConfigDB::number_t | |
| static constexpr const number_t | min () |
| Smallest positive value. More... | |
| static constexpr const number_t | max () |
| Largest positive value. More... | |
| static constexpr const number_t | lowest () |
| Most negative value. More... | |
| static double | asFloat (number_t number) |
| static int64_t | asInt64 (number_t number) |
| static int | compare (number_t num1, number_t num2) |
| static const char * | format (char *buf, number_t number) |
| Convert number to string. More... | |
| static bool | parse (const char *value, unsigned length, number_t &number) |
| static number_t | parse (const char *value, unsigned length) |
| static constexpr number_t | normalise (unsigned mantissa, int exponent, bool isNeg) |
| Produce a normalised number_t from component values. More... | |
| static constexpr number_t | normalise (double mantissa) |
| static constexpr number_t | normalise (int mantissa, int exponent) |
| static constexpr number_t | normalise (int64_t value) |
Public Attributes inherited from ConfigDB::number_t | |
| int32_t | mantissa: 26 |
| int32_t | exponent: 6 |
Static Public Attributes inherited from ConfigDB::number_t | |
| static constexpr unsigned | maxMantissa {0x1ffffff} |
| static constexpr int | maxExponent {0x1f} |
| static constexpr unsigned | maxSignificantDigits {8} |
| static constexpr unsigned | minBufferSize {17} |
Detailed Description
Compile-time constant number.
Must be assigned to a constexpr variable to guarantee compile-time evaluation. For example:
constexpr const_number_t constnum(3.14);
This is typically used to generate numbers stored directly in flash memory, where the structure definition is itself declared constexpr.
By inspection, compilers tend to generate runtime code when used normally:
const_number_t constnum(3.14);
This behaviour is because floating-point numbers are not exact representations (integral) so the compiler is erring on the safe side.
Constructor & Destructor Documentation
◆ const_number_t() [1/2]
|
default |
◆ const_number_t() [2/2]
|
inlineconstexpr |
Computer number from a compile-time constant value.
The documentation for this struct was generated from the following file:
Public Member Functions inherited from
1.9.1