Functions
-
template <class T>std::enable_if_t<! std::is_unsigned<T>::value, bool> IsNegative (const T & v)Defined at line 165 of file ../../third_party/abseil-cpp/absl/strings/numbers.h
-
template <class T>std::enable_if_t<std::is_unsigned<T>::value, std::false_type> IsNegative (const T & )Defined at line 170 of file ../../third_party/abseil-cpp/absl/strings/numbers.h
-
template <typename T>std::enable_if_t<std::is_unsigned<T>::value, uint32_t> Base10Digits (T v, const uint32_t initial_digits)Returns the number of base-10 digits in the given number.
Note that this strictly counts digits. It does not count the sign.
The `initial_digits` parameter is the starting point, which is normally equal
to 1 because the number of digits in 0 is 1 (a special case).
However, callers may e.g. wish to change it to 2 to account for the sign.
Defined at line 198 of file ../../third_party/abseil-cpp/absl/strings/numbers.h
-
template <typename T>std::enable_if_t<std::is_signed<T>::value, uint32_t> Base10Digits (T v, uint32_t r)Defined at line 223 of file ../../third_party/abseil-cpp/absl/strings/numbers.h
-
template <typename int_type>absl::Nonnull<char *> FastIntToBuffer (int_type i, absl::Nonnull<char *> buffer)For enums and integer types that are not an exact match for the types above,
use templates to call the appropriate one of the four overloads above.
Defined at line 273 of file ../../third_party/abseil-cpp/absl/strings/numbers.h
-
template <typename int_type>absl::Nonnull<char *> FastIntToBufferBackward (int_type i, absl::Nonnull<char *> buffer_end, uint32_t exact_digit_count)For enums and integer types that are not an exact match for the types above,
use templates to call the appropriate one of the four overloads above.
Defined at line 318 of file ../../third_party/abseil-cpp/absl/strings/numbers.h
-
size_t FastHexToBufferZeroPad16 (uint64_t val, absl::Nonnull<char *> out)FastHexToBufferZeroPad16()
Outputs `val` into `out` as if by `snprintf(out, 17, "%016x", val)` but
without the terminating null character. Thus `out` must be of length >= 16.
Returns the number of non-pad digits of the output (it can never be zero
since 0 has one digit).
Defined at line 396 of file ../../third_party/abseil-cpp/absl/strings/numbers.h
-
void PutTwoDigits (uint32_t i, absl::Nonnull<char *> buf)Writes a two-character representation of 'i' to 'buf'. 'i' must be in the
range 0
<
= i
<
100, and buf must have space for two characters. Example:
char buf[2];
PutTwoDigits(42, buf);
// buf[0] == '4'
// buf[1] == '2'
-
bool safe_strto32_base (absl::string_view text, absl::Nonnull<int32_t *> value, int base)safe_strto?() functions for implementing SimpleAtoi()
-
bool safe_strto64_base (absl::string_view text, absl::Nonnull<int64_t *> value, int base) -
bool safe_strto128_base (absl::string_view text, absl::Nonnull<absl::int128 *> value, int base) -
bool safe_strtou32_base (absl::string_view text, absl::Nonnull<uint32_t *> value, int base) -
bool safe_strtou64_base (absl::string_view text, absl::Nonnull<uint64_t *> value, int base) -
bool safe_strtou128_base (absl::string_view text, absl::Nonnull<absl::uint128 *> value, int base) -
int GetNumDigitsOrNegativeIfNegative (signed char v)These functions return the number of base-10 digits, but multiplied by -1 if
the input itself is negative. This is handy and efficient for later usage,
since the bitwise complement of the result becomes equal to the number of
characters required.
-
int GetNumDigitsOrNegativeIfNegative (unsigned char v) -
int GetNumDigitsOrNegativeIfNegative (short v) -
int GetNumDigitsOrNegativeIfNegative (unsigned short v) -
int GetNumDigitsOrNegativeIfNegative (int v) -
int GetNumDigitsOrNegativeIfNegative (unsigned int v) -
int GetNumDigitsOrNegativeIfNegative (long v) -
int GetNumDigitsOrNegativeIfNegative (unsigned long v) -
int GetNumDigitsOrNegativeIfNegative (long long v) -
int GetNumDigitsOrNegativeIfNegative (unsigned long long v) -
size_t SixDigitsToBuffer (double d, absl::Nonnull<char *> buffer)Helper function for fast formatting of floating-point values.
The result is the same as printf's "%g", a.k.a. "%.6g"; that is, six
significant digits are returned, trailing zeros are removed, and numbers
outside the range 0.0001-999999 are output using scientific notation
(1.23456e+06). This routine is heavily optimized.
Required buffer size is `kSixDigitsToBufferSize`.
-
absl::Nonnull<char *> FastIntToBuffer (int32_t i, absl::Nonnull<char *> buffer)All of these functions take an output buffer
as an argument and return a pointer to the last byte they wrote, which is the
terminating '
\
0'. At most `kFastToBufferSize` bytes are written.
-
absl::Nonnull<char *> FastIntToBuffer (uint32_t i, absl::Nonnull<char *> buffer) -
absl::Nonnull<char *> FastIntToBuffer (int64_t i, absl::Nonnull<char *> buffer) -
absl::Nonnull<char *> FastIntToBuffer (uint64_t i, absl::Nonnull<char *> buffer) -
absl::Nonnull<char *> FastIntToBufferBackward (int32_t i, absl::Nonnull<char *> buffer_end, uint32_t exact_digit_count)These functions do NOT add any null-terminator.
They return a pointer to the beginning of the written string.
The digit counts provided must *exactly* match the number of base-10 digits
in the number, or the behavior is undefined.
(i.e. do NOT count the minus sign, or over- or under-count the digits.)
-
absl::Nonnull<char *> FastIntToBufferBackward (uint32_t i, absl::Nonnull<char *> buffer_end, uint32_t exact_digit_count) -
absl::Nonnull<char *> FastIntToBufferBackward (int64_t i, absl::Nonnull<char *> buffer_end, uint32_t exact_digit_count) -
absl::Nonnull<char *> FastIntToBufferBackward (uint64_t i, absl::Nonnull<char *> buffer_end, uint32_t exact_digit_count) -
template <class T>std::enable_if_t<std::is_unsigned<std::decay_t<T>>::value, T &&> UnsignedAbsoluteValue (T && v)Defined at line 178 of file ../../third_party/abseil-cpp/absl/strings/numbers.h
-
template <class T>std::enable_if_t<! std::is_unsigned<T>::value, std::make_unsigned_t<T>> UnsignedAbsoluteValue (T v)Defined at line 186 of file ../../third_party/abseil-cpp/absl/strings/numbers.h
-
template <typename int_type>bool safe_strtoi_base (absl::string_view sabsl::Nonnull<int_type *> outint base)Implementation of SimpleAtoi, generalized to support arbitrary base (used
with base different from 10 elsewhere in Abseil implementation).
Defined at line 352 of file ../../third_party/abseil-cpp/absl/strings/numbers.h
Variables
const char[17] kHexChar
const char[513] kHexTable