FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
FARGOS Fast Numeric Conversion Functions

These functions quickly convert between ASCII and integer, floating-point and fixed-point values. More...

Classes

struct  VariableFixedPointValue
 Return value structure for representing fixed-point values with variable precision. More...
 
union  Aligned4Chars
 Table of word-aligned 4-character groups representing 0000-9999. More...
 

Macros

#define CONVERT_UINT_TO_TEXT(varName, sourceVal)   uint32_t _workBfr_ ## varName [6]; char *varName = uint_to_ascii(_workBfr_ ## varName, sizeof(_workBfr_ ## varName), sourceVal)
 Convenience macro to declare a work buffer and convert an unsigned value into text. More...
 
#define CONVERT_INT_TO_TEXT(varName, sourceVal)   uint32_t _workBfr_ ## varName [6]; char *varName = int_to_ascii(_workBfr_ ## varName, sizeof(_workBfr_ ## varName), sourceVal);
 Convenience macro to declare a work buffer and convert a signed value into text. If the value is known to be positive, CONVERT_UINT_TO_TEXT() is faster. More...
 

Functions

uint_fast32_t text2uint32 (const char *textString, uint_fast8_t text_len)
 Convert a sequence of text characters into an unsigned integer as quickly as possible. Depending on string length, this routine is between 2-3 times faster than standard routines such as strtol(). Note: text2int32() can be used if negative numbers will be seen. More...
 
int_fast32_t text2int32 (const char *textString, uint_fast8_t text_len)
 Convert a sequence of text characters into a 32-bit signed integer as quickly as possible. Optional leading "-" or "+" supported. More...
 
uint64_t text2uint64 (const char *textString, uint_fast8_t text_len)
 Convert a sequence of text characters into a 64-bit unsigned integer as quickly as possible. More...
 
int64_t text2int64 (const char *textString, uint_fast8_t text_len)
 Convert a sequence of text characters into a 64-bit signed integer as quickly as possible. Optional leading "-" or "+" supported. More...
 
uint32_t n2to_uint32 (const void *byteData)
 Convert a network byte order 2-byte integer into a native unsigned 32-bit value. More...
 
uint32_t n4to_uint32 (const void *byteData)
 Convert a network byte order 4-byte integer into a native unsigned 32-bit value. More...
 
uint64_t n8to_uint64 (const void *byteData)
 Convert a network byte order 8-byte integer into a native unsigned 64-bit value. More...
 
CONSTEXPR uint16_t const_uint16_ton2 (const uint16_t arg) OME_ALWAYS_INLINE OME_PURE_FUNCTION OME_ALWAYS_OPTIMIZE("-O3")
 Equivalent of htons(), but evaluated at compile time. More...
 
CONSTEXPR uint32_t const_uint32_ton4 (const uint32_t arg) OME_ALWAYS_INLINE OME_PURE_FUNCTION OME_ALWAYS_OPTIMIZE("-O3")
 Equivalent of htonl(), but evaluated at compile time. More...
 
CONSTEXPR uint64_t const_uint64_ton8 (const uint64_t arg) OME_ALWAYS_INLINE OME_PURE_FUNCTION OME_ALWAYS_OPTIMIZE("-O3")
 Equivalent of htonll(), but evaluated at compile time. More...
 
char * uint_to_ascii (uint32_t workBfr[], uint_fast8_t bfrLen, uint64_t value, uint_fast8_t *retStrLen=nullptr) NONNULL_RETURN
 Quickly convert a binary integer into ASCII decimal text. More...
 
char * int_to_ascii (uint32_t workBfr[], uint_fast8_t bfrLen, int64_t value, uint_fast8_t *retStrLen=nullptr) NONNULL_RETURN
 Identical to uint_to_ascii(), except that negative values are accepted. More...
 
char * uint_to_ascii_right_justified (uint32_t workBfr[], uint_fast8_t bfrLen, uint64_t value, uint_fast8_t fieldWidth, char fillChar=' ') NONNULL_RETURN
 Convert a binary integer into right-justified ASCII decimal text and pad on the left with a specified fill character. More...
 
char * fixedpoint_to_ascii (char *resultBfr, uint_fast8_t bfrLen, int64_t value, uint_fast8_t decimals, uint_fast8_t *retStrLen=nullptr, int_fast8_t outputPrecision=-2) NONNULL_RETURN
 Format a fixed-point value with indicated decimal places. More...
 
VariableFixedPointValue fast_ascii_to_fixedpoint (const char *str, uint_fast8_t len=0, int_fast8_t desiredPrecision=-2) NONNULL_PARAMETERS(1)
 Convert ASCII decimal text string to fixed point representation. More...
 
int64_t ascii_to_fixedpoint (const char *str, uint_fast8_t *resultPrecision=nullptr, uint_fast8_t len=0, int_fast8_t desiredPrecision=-2) NONNULL_PARAMETERS(1) OME_ALWAYS_INLINE
 Convert ASCII decimal text string to fixed point representation. More...
 
double text2double (const char *str, uint_fast8_t len=0) NONNULL_PARAMETERS(1)
 Convert ASCII decimal text string to a double. More...
 
char * float_to_ascii (char *resultBfr, uint_fast8_t bfrLen, double value, uint_fast8_t *retStrLen=nullptr, int_fast8_t outputPrecision=-2, bool roundValue=false) NONNULL_PARAMETERS(1) NONNULL_RETURN
 Format a double-precision value with indicated decimal places. More...
 
uint_fast8_t bytesInUTFcharacter (const char val)
 Return number of bytes required to represent UTF-encoded character as indicated by value of leading byte. More...
 
uint_fast8_t bytesInUTFchar (const void *s)
 Return number of bytes required to represent UTF-encoded character pointed to by argument. More...
 
template<unsigned int EXPONENT>
CONSTEXPR uint64_t powerOf10Constant ()
 Generate compile-time constant for integral power of 10. More...
 
template<unsigned int LEN>
uint_fast32_t right_padded_strlen (const char *s, const char PADDING_CHAR)
 Templated convenience routine to return the length of a possibly padded string. The assumption is that the string is padded on the right with a consistent padding character up to a predefined length. More...
 
template<>
uint_fast32_t right_padded_strlen< 0 > (const char *s, const char PADDING_CHAR)
 specialization to stop recursion at length 0 More...
 
template<uint_fast8_t FIELD_LEN>
uint64_t textField2uint (const char *field)
 Templated ASCII-to-integer conversion routine that very quickly converts fixed-length fields of positive integers. More...
 
template<uint_fast8_t FIELD_LEN>
int64_t textField2int (const char *field)
 Templated ASCII-to-integer conversion routine that converts fixed-length fields. More...
 
CONSTEXPR double cleanedNumericValue (double v, double minPrecision)
 Return value clipped to 0 if not above a threshold of precision. More...
 
CONSTEXPR double cleanedPositiveNumericValue (double v, double minPrecision)
 Return value clipped to 0 if not above a threshold of precision. More...
 
template<typename STREAMTYPE >
STREAMTYPE & operator<< (STREAMTYPE &os, const VariableFixedPointValue arg)
 

Variables

const uint32_t powersOf10 [10]
 Table of powers-of-10 constants as 32-bit unsigned integers. More...
 
const uint64_t powersOf10_64bit [16]
 Table of powers-of-10 constants as 64-bit unsigned integers. More...
 
const double floatingPowersOf10 [10]
 Table of powers-of-10 constants as floating-point values. More...
 
const double reciprocalPowersOf10 [16]
 Table of reciprocal powers-of-10 divisors. More...
 
const uint32_t text2int_table [256][10]
 Convert ASCII digit into corresponding 32-bit value. More...
 
const uint64_t text2int64_table [256][20]
 Convert ASCII digit into corresponding 64-bit value. More...
 
const char byteAsLowercaseHexadecimal [256][3]
 Table of uppercase hexadecimal characters for each byte value. More...
 
const char byteAsUppercaseHexadecimal [256][3]
 Table of uppercase hexadecimal characters for each byte value. More...
 
const char numberAsTwoDigits [100][3]
 Table of 2-character strings representing 00-99. More...
 
const union Aligned4Chars numberAs4Digits [10000]
 

Detailed Description

These functions quickly convert between ASCII and integer, floating-point and fixed-point values.

Macro Definition Documentation

◆ CONVERT_INT_TO_TEXT

#define CONVERT_INT_TO_TEXT (   varName,
  sourceVal 
)    uint32_t _workBfr_ ## varName [6]; char *varName = int_to_ascii(_workBfr_ ## varName, sizeof(_workBfr_ ## varName), sourceVal);

Convenience macro to declare a work buffer and convert a signed value into text. If the value is known to be positive, CONVERT_UINT_TO_TEXT() is faster.

Parameters
varNamespecifies the name of the new variable to be declared. It will point to the text result.
sourceValspecifies the integer value to be converted

◆ CONVERT_UINT_TO_TEXT

#define CONVERT_UINT_TO_TEXT (   varName,
  sourceVal 
)    uint32_t _workBfr_ ## varName [6]; char *varName = uint_to_ascii(_workBfr_ ## varName, sizeof(_workBfr_ ## varName), sourceVal)

Convenience macro to declare a work buffer and convert an unsigned value into text.

Parameters
varNamespecifies the name of the new variable to be declared. It will point to the text result.
sourceValspecifies the integer value to be converted

Function Documentation

◆ ascii_to_fixedpoint()

int64_t ascii_to_fixedpoint ( const char *  str,
uint_fast8_t *  resultPrecision = nullptr,
uint_fast8_t  len = 0,
int_fast8_t  desiredPrecision = -2 
)
inline

Convert ASCII decimal text string to fixed point representation.

Parameters
strpoints to the text string to be converted
resultPrecisionis an optional argument that points at a location into which the apparent precision of the source string will be stored.
lenis an optional argument that indicates the length of the source string. If specified as 0, strlen() will be used to determine the length.
desiredPrecisionis an optional parameter that specifies the desired precision of the result; it will be scaled to meet the constraint. A value of -2 indicates to use the precision implied by the source string.
See also
fast_ascii_to_fixedpoint()

References fast_ascii_to_fixedpoint(), VariableFixedPointValue::precision, and VariableFixedPointValue::value.

Referenced by text2double().

◆ bytesInUTFchar()

uint_fast8_t bytesInUTFchar ( const void *  s)
inline

Return number of bytes required to represent UTF-encoded character pointed to by argument.

References bytesInUTFcharacter(), and s.

◆ bytesInUTFcharacter()

uint_fast8_t bytesInUTFcharacter ( const char  val)
inline

Return number of bytes required to represent UTF-encoded character as indicated by value of leading byte.

References OME_EXPECT_TRUE, and Aligned4Chars::val.

Referenced by bytesInUTFchar().

◆ cleanedNumericValue()

CONSTEXPR double cleanedNumericValue ( double  v,
double  minPrecision 
)
inline

Return value clipped to 0 if not above a threshold of precision.

Parameters
vspecifies the value
minPrecisionspecifies the minimum precision.
Returns
The value of zero will be returned if v is within the range (-minPrecision,+minPrecision); otherwise v will be returned.

◆ cleanedPositiveNumericValue()

CONSTEXPR double cleanedPositiveNumericValue ( double  v,
double  minPrecision 
)
inline

Return value clipped to 0 if not above a threshold of precision.

Parameters
vspecifies the value that is supposed to be positive.
minPrecisionspecifies the minimum precision.

The value of zero will be returned if v is not at least minPrecision. Note that this means that any values below minPrecision will be treated as 0.

◆ const_uint16_ton2()

CONSTEXPR uint16_t const_uint16_ton2 ( const uint16_t  arg)
inline

Equivalent of htons(), but evaluated at compile time.

◆ const_uint32_ton4()

CONSTEXPR uint32_t const_uint32_ton4 ( const uint32_t  arg)
inline

Equivalent of htonl(), but evaluated at compile time.

◆ const_uint64_ton8()

CONSTEXPR uint64_t const_uint64_ton8 ( const uint64_t  arg)
inline

Equivalent of htonll(), but evaluated at compile time.

◆ fast_ascii_to_fixedpoint()

VariableFixedPointValue fast_ascii_to_fixedpoint ( const char *  str,
uint_fast8_t  len = 0,
int_fast8_t  desiredPrecision = -2 
)

Convert ASCII decimal text string to fixed point representation.

Parameters
strpoints to the text string to be converted
lenis an optional argument that indicates the length of the source string. If specified as 0, strlen() will be used to determine the length.
desiredPrecisionis an optional parameter that specifies the desired precision of the result; it will be scaled to meet the constraint. A value of -2 indicates to use the precision implied by the source string.
Note
:

References l, OME_EXPECT_TRUE, OME_PREFETCH, powersOf10_64bit, VariableFixedPointValue::precision, text2int64(), text2uint64(), and VariableFixedPointValue::value.

Referenced by ascii_to_fixedpoint(), and defaultConvertAndTransferField().

◆ fixedpoint_to_ascii()

char* fixedpoint_to_ascii ( char *  resultBfr,
uint_fast8_t  bfrLen,
int64_t  value,
uint_fast8_t  decimals,
uint_fast8_t *  retStrLen = nullptr,
int_fast8_t  outputPrecision = -2 
)

Format a fixed-point value with indicated decimal places.

Parameters
resultBfrprovides space into which the ASCII decimal text will be placed.
bfrLenspecifies the length of the provided buffer.
valuespecifies the fixed-point value to be output.
decimalsspecifies the implied number of decimal places of precision.
retStrLenis an optional argument that points to a location into which the size of the result string will be placed.
outputPrecisionis an optional parameter that specifies the desired output precision of the formatted result. The default value of -2 is used to indicate the precision specified by decimals should be used as-is. A value of -3 is used to request truncation to the minimum required precision. A value of -1 indicates truncation to an integer with no decimal point whereas a value of 0 will truncate to an integer result but retain a trailing decimal point.

References int_to_ascii(), OME_EXPECT_FALSE, OME_EXPECT_TRUE, and stderr.

Referenced by defaultConvertAndTransferField(), float_to_ascii(), LogMessageRecord::formatRecordAsText(), operator<<(), and ReadBinaryLog::outputAssembledLine().

◆ float_to_ascii()

char* float_to_ascii ( char *  resultBfr,
uint_fast8_t  bfrLen,
double  value,
uint_fast8_t *  retStrLen = nullptr,
int_fast8_t  outputPrecision = -2,
bool  roundValue = false 
)

Format a double-precision value with indicated decimal places.

Parameters
resultBfrprovides space into which the ASCII text will be placed.
bfrLenspecifies the length of the provided buffer.
valuespecifies the floating-point value to be output.
retStrLenis an optional argument that points to a location into which the size of the result string will be placed.
outputPrecisionis an optional parameter that specifies the desired output precision of the formatted result. The value of -2 is used to indicate a minimal amount of precision should be used, but at least one decimal place will be displayed. A value of -1 indicates truncation to an integer with no decimal point whereas a value of 0 will truncate to an integer result but retain a trailing decimal point.
roundValueis an optional Boolean flag that indicates if the floating-point value should be rounded to the nearest integer or simply truncated (the default operation).
Note
This reentrant routine is more than an order of magnitude faster than sprintf() and accomplishes its work without any division.

References fixedpoint_to_ascii(), floatingPowersOf10, OME_EXPECT_FALSE, OME_EXPECT_TRUE, OME_PREFETCH, and safe_strcpy.

Referenced by defaultConvertAndTransferField(), LogMessageRecord::formatRecordAsText(), and OMEtype::outputOnStream().

◆ int_to_ascii()

char* int_to_ascii ( uint32_t  workBfr[],
uint_fast8_t  bfrLen,
int64_t  value,
uint_fast8_t *  retStrLen = nullptr 
)

◆ n2to_uint32()

uint32_t n2to_uint32 ( const void *  byteData)
inline

Convert a network byte order 2-byte integer into a native unsigned 32-bit value.

◆ n4to_uint32()

uint32_t n4to_uint32 ( const void *  byteData)
inline

Convert a network byte order 4-byte integer into a native unsigned 32-bit value.

Referenced by defaultConvertAndTransferField().

◆ n8to_uint64()

uint64_t n8to_uint64 ( const void *  byteData)
inline

Convert a network byte order 8-byte integer into a native unsigned 64-bit value.

◆ operator<<()

template<typename STREAMTYPE >
STREAMTYPE& operator<< ( STREAMTYPE &  os,
const VariableFixedPointValue  arg 
)

◆ powerOf10Constant()

template<unsigned int EXPONENT>
CONSTEXPR uint64_t powerOf10Constant ( )
inline

Generate compile-time constant for integral power of 10.

NOTE: the return type is a 64-bit unsigned, which permits values of up to 10-to-the-19th to be represented. Currently EXPONENT values greater than 19 are accepted without complaint.

Referenced by TimePointOfGranularity< UNITS >::operator=().

◆ right_padded_strlen()

template<unsigned int LEN>
uint_fast32_t right_padded_strlen ( const char *  s,
const char  PADDING_CHAR 
)
inline

Templated convenience routine to return the length of a possibly padded string. The assumption is that the string is padded on the right with a consistent padding character up to a predefined length.

  • LEN specifies the apparent length of the string; typically this is the field width.
    Parameters
    spoints to the string to be examined.
    PADDING_CHARspecifies the padding character; it defaults to a space.
    Returns
    A value between 0 and LEN will be returned, representing the offset+1 of the last character in the string before the padding characters appear.
    Note
    Although this is not declared as a constexpr, the compiler can determine the length at compile time if the source was compiled with optimization and the function was passed a string constant.

References s.

◆ right_padded_strlen< 0 >()

template<>
uint_fast32_t right_padded_strlen< 0 > ( const char *  s,
const char  PADDING_CHAR 
)
inline

specialization to stop recursion at length 0

◆ text2double()

double text2double ( const char *  str,
uint_fast8_t  len = 0 
)

Convert ASCII decimal text string to a double.

Parameters
strpoints to the text string to be converted
lenis an option argument that indicates the length of the source string. If specified as 0, strlen() will be used to determine the length.
Note
scientific notation is tolerated; however, values below 10^-10 will be treated as 0 and values above 10^10 will be calculated using the pow() library function.

References ascii_to_fixedpoint(), floatingPowersOf10, OME_EXPECT_TRUE, reciprocalPowersOf10, and text2int32().

◆ text2int32()

int_fast32_t text2int32 ( const char *  textString,
uint_fast8_t  text_len 
)
inline

Convert a sequence of text characters into a 32-bit signed integer as quickly as possible. Optional leading "-" or "+" supported.

Note
use text2uint32() when number is known to be positive.

References OME_EXPECT_TRUE, OME_PREFETCH, text2uint32(), and Aligned4Chars::val.

Referenced by text2double().

◆ text2int64()

int64_t text2int64 ( const char *  textString,
uint_fast8_t  text_len 
)
inline

Convert a sequence of text characters into a 64-bit signed integer as quickly as possible. Optional leading "-" or "+" supported.

Note
use text2uint64() when number is known to be positive.
See also
textField2int() is an even faster routine suitable for use by C++ source.

References OME_EXPECT_TRUE, OME_PREFETCH, text2uint64(), and Aligned4Chars::val.

Referenced by fast_ascii_to_fixedpoint().

◆ text2uint32()

uint_fast32_t text2uint32 ( const char *  textString,
uint_fast8_t  text_len 
)
inline

Convert a sequence of text characters into an unsigned integer as quickly as possible. Depending on string length, this routine is between 2-3 times faster than standard routines such as strtol(). Note: text2int32() can be used if negative numbers will be seen.

See also
For C++ code, textField2uint() is an even faster routine that can be used in the rare cases that the field length is known at compile time. The generic fastTextField2int() is also provides a faster implementation for C++ source but drops the requirement of knowing the field length at compile time.

References CACHE_LINE_LENGTH, OME_PREFETCH, and text2int_table.

Referenced by TimePointOfGranularity< UNITS >::convertDayAndTime(), Parse_And_Process_HTTP_Stream::processHTTPheader(), GenericSocketAddress::setFromURL(), and text2int32().

◆ text2uint64()

uint64_t text2uint64 ( const char *  textString,
uint_fast8_t  text_len 
)
inline

Convert a sequence of text characters into a 64-bit unsigned integer as quickly as possible.

Note
text2int64() can be used if negative numbers will be seen.

References CACHE_LINE_LENGTH, OME_PREFETCH, and text2int64_table.

Referenced by fast_ascii_to_fixedpoint(), and text2int64().

◆ textField2int()

template<uint_fast8_t FIELD_LEN>
int64_t textField2int ( const char *  field)

Templated ASCII-to-integer conversion routine that converts fixed-length fields.

FIELD_LEN is the template parameter and specifies the field length. Unlike text2uint(), the length of the field is must be known at compile time.

Parameters
fieldpoints at the start of the text field.
Note
In contrast to textField2uint(), this routine recognizes a leading minus sign, accepts a leading plus sign, and tolerates leading spaces.
See also
text2uint(), textField2int()

◆ textField2uint()

template<uint_fast8_t FIELD_LEN>
uint64_t textField2uint ( const char *  field)
inline

Templated ASCII-to-integer conversion routine that very quickly converts fixed-length fields of positive integers.

FIELD_LEN is the template parameter and specifies the field length. Unlike text2uint(), the length of the field is must be known at compile time.

Parameters
fieldpoints at the start of the text field.

This routine can be more than 5 to 8 times faster than standard routines such as strtol(). Unfortunately, the opportunity for a field's length to be known at compile time is rarely encountered. One compromise is to add the overhead of a test on field length and then select the custom call for that particular length.

Note
In contrast to text2uint(), this routine does not tolerate the field containing anything but the digits 0 through 9. With higher levels of optimization, the compiler can evaluate this code at compile time if the text field content itself is constant.
See also
text2uint(), textField2int()

◆ uint_to_ascii()

char* uint_to_ascii ( uint32_t  workBfr[],
uint_fast8_t  bfrLen,
uint64_t  value,
uint_fast8_t *  retStrLen = nullptr 
)

Quickly convert a binary integer into ASCII decimal text.

Parameters
workBfrprovides space into which the ASCII text will be placed. An array of uint32_t is requested in order to ensure proper alignment for performance (and correctness on machines where unaligned access results in a bus error). A minimum of a 6-element uint32_t array is required.
bfrLenspecifies the size of the provided work buffer in bytes; at least 24 bytes should be provided. This value should always be a multiple of sizeof(uint32_t), which is 4.
valuespecifies the 64-bit unsigned value to be output.
retStrLenis an optional argument that points at an uint32_t that will be provided with the length of the generated string.
Returns
a pointer to the start of the generated null-terminated text string is returned.
Note
This reentrant routine is more than an order of magnitude faster than sprintf().
See also
CONVERT_UINT_TO_TEXT()

References Aligned4Chars::digits, Aligned4Chars::lastThreeDigits, Aligned4Chars::lastTwoDigits, numberAs4Digits, OME_EXPECT_TRUE, and Aligned4Chars::val.

Referenced by defaultConvertAndTransferField(), LogMessageRecord::formatRecordAsText(), int_to_ascii(), ReadBinaryLog::outputAssembledLine(), OMEtype::outputOnStream(), and uint_to_ascii_right_justified().

◆ uint_to_ascii_right_justified()

char* uint_to_ascii_right_justified ( uint32_t  workBfr[],
uint_fast8_t  bfrLen,
uint64_t  value,
uint_fast8_t  fieldWidth,
char  fillChar = ' ' 
)

Convert a binary integer into right-justified ASCII decimal text and pad on the left with a specified fill character.

Parameters
workBfrprovides space into which the ASCII text will be placed. An array of uint32_t is requested in order to ensure proper alignment for performance (and correctness on machines where unaligned access results in a bus error). A minimum of a 6-element uint32_t array is required.
bfrLenspecifies the size of the provided work buffer in bytes; at least 24 bytes should be provided.
valuespecifies the 64-bit unsigned value to be output.
fieldWidthspecifies the desired width of the field.
fillCharspecifies the fill character to pad unused positions on the left. If not specified, it defaults to a space.
Note
Uses uint_to_ascii() for conversion.
Returns
a pointer to the start of the generated null-terminated text string is returned.

References uint_to_ascii().

Referenced by TimePointOfGranularity< UNITS >::formatIntoString().

Variable Documentation

◆ byteAsLowercaseHexadecimal

const char byteAsLowercaseHexadecimal[256][3]

Table of uppercase hexadecimal characters for each byte value.

Referenced by LogMessageRecord::formatRecordAsText(), operator<<(), and ReadBinaryLog::outputAssembledLine().

◆ byteAsUppercaseHexadecimal

const char byteAsUppercaseHexadecimal[256][3]

Table of uppercase hexadecimal characters for each byte value.

Referenced by LogMessageRecord::formatRecordAsText(), operator<<(), and ReadBinaryLog::outputAssembledLine().

◆ floatingPowersOf10

const double floatingPowersOf10[10]
Initial value:
= {
1, 10, 100, 1000, 10000, 100000,
1000000, 10000000, 100000000, 1000000000
}

Table of powers-of-10 constants as floating-point values.

See also
powerOf10Constant()

Referenced by float_to_ascii(), and text2double().

◆ numberAs4Digits

const union Aligned4Chars numberAs4Digits[10000]

◆ numberAsTwoDigits

const char numberAsTwoDigits[100][3]

Table of 2-character strings representing 00-99.

Referenced by TimePointOfGranularity< UNITS >::formatIntoString().

◆ powersOf10

const uint32_t powersOf10[10]
Initial value:
= {
1, 10, 100, 1000, 10000, 100000,
1000000, 10000000, 100000000, 1000000000U
}

Table of powers-of-10 constants as 32-bit unsigned integers.

See also
powerOf10Constant()

Referenced by defaultConvertAndTransferField().

◆ powersOf10_64bit

const uint64_t powersOf10_64bit[16]
Initial value:
= {
1, 10, 100, 1000, 10000, 100000,
1000000, 10000000, 100000000, 1000000000U,
static_cast<uint64_t>(1000000000U) * 10,
static_cast<uint64_t>(1000000000U) * 100,
static_cast<uint64_t>(1000000000U) * 1000,
static_cast<uint64_t>(1000000000U) * 10000,
static_cast<uint64_t>(1000000000U) * 100000,
static_cast<uint64_t>(1000000000U) * 1000000
}

Table of powers-of-10 constants as 64-bit unsigned integers.

See also
powerOf10Constant()

Referenced by fast_ascii_to_fixedpoint().

◆ reciprocalPowersOf10

const double reciprocalPowersOf10[16]
Initial value:
= {
1, 0.1, 0.01, 0.001, 0.0001,
0.00001, 0.000001, 0.0000001,
0.00000001, 0.000000001,
0.0000000001,
0.00000000001,
0.000000000001,
0.0000000000001,
0.00000000000001,
0.000000000000001,
}

Table of reciprocal powers-of-10 divisors.

It is often an order-of-magnitude faster to multiply by a reciprocal than perform a division, so this table of reciprocals is used to divide numbers by various powers-of-10.

See also
powerOf10Constant()

Referenced by text2double().

◆ text2int64_table

const uint64_t text2int64_table[256][20]

Convert ASCII digit into corresponding 64-bit value.

Referenced by text2uint64().

◆ text2int_table

const uint32_t text2int_table[256][10]
Initial value:
= {
{ 0, 0, 0, 0, 0, 0, 0, 0, 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 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{
1, 10, 100, 1000, 10000, 100000,
1000000, 10000000, 100000000, 1000000000U
},
{
2, 20, 200, 2000, 20000, 200000,
2000000, 20000000, 200000000, 2000000000U
},
{
3, 30, 300, 3000, 30000, 300000,
3000000, 30000000, 300000000, 3000000000U
},
{
4, 40, 400, 4000, 40000, 400000,
4000000, 40000000, 400000000, 4000000000U
},
{
5, 50, 500, 5000, 50000, 500000,
5000000, 50000000, 500000000, ~0U
},
{
6, 60, 600, 6000, 60000, 600000,
6000000, 60000000, 600000000, ~0U
},
{
7, 70, 700, 7000, 70000, 700000,
7000000, 70000000, 700000000, ~0U
},
{
8, 80, 800, 8000, 80000, 800000,
8000000, 80000000, 800000000, ~0U
},
{
9, 90, 900, 9000, 90000, 900000,
9000000, 90000000, 900000000, ~0U
},
{ 0,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 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
}

Convert ASCII digit into corresponding 32-bit value.

Warning
numbers greater than 2^32 won't be converted correctly. Use the text2int64_table[] if numbers >= 5 billion are to be converted.
See also
text2int64_table

Referenced by text2uint32().

Generated: Fri Jul 31 2020 18:19:16
Support Information