#include <TargConfig.h>
Go to the source code of this file.
|
| BA_API U64 | U64_atoll (const char *s) |
| | Convert a decimal string to a 64-bit integer representation. More...
|
| |
| BA_API U64 | U64_atoll2 (const char *s, const char *e) |
| | Convert a bounded decimal character sequence to a 64-bit representation. More...
|
| |
| BA_API U32 | U32_negate (U32 n) |
| | Negate a 32-bit integer representation. More...
|
| |
| BA_API U32 | U32_atoi (const char *s) |
| | Convert a decimal string, rounding an optional fraction. More...
|
| |
| BA_API U32 | U32_atoi2 (const char *s, const char *e) |
| | Convert a bounded decimal sequence with the rounding used by U32_atoi. More...
|
| |
| BA_API U32 | U32_hextoi (const char *s) |
| | Convert an unsigned hexadecimal string. More...
|
| |
◆ S64_atoll
Convert a decimal string and cast the result to S64.
- Parameters
-
| [in] | s | NUL-terminated decimal string or NULL. See U64_atoll for the input requirements; the value must be representable as S64. |
- Returns
- The signed value, or zero for NULL or an empty string.
◆ U32_atoi()
| BA_API U32 U32_atoi |
( |
const char * |
s | ) |
|
Convert a decimal string, rounding an optional fraction.
- Parameters
-
| [in] | s | NUL-terminated decimal string, optionally starting with '-'; NULL is allowed. The caller must supply valid decimal digits, at most one '.', and a value whose conversion and optional signed negation are representable. Whitespace and '+' are not supported by this contract. |
- Returns
- The rounded value represented as U32, or zero for NULL or an empty string. A first fractional digit of 5 through 9 rounds the magnitude up; other fractional digits are ignored. Negative values round away from zero at a half and are returned in unsigned representation.
- Note
- Invalid input and overflow are not reported. This is not an input validation function.
◆ U32_atoi2()
| BA_API U32 U32_atoi2 |
( |
const char * |
s, |
|
|
const char * |
e |
|
) |
| |
Convert a bounded decimal sequence with the rounding used by U32_atoi.
- Parameters
-
| [in] | s | Start of the sequence, or NULL to return zero. |
| [in] | e | End of the integer scan, in the same buffer as s, with e >= s. Ignored when s is NULL. The implementation also reads the character at e; if that character is '.', it reads the following character for rounding. These positions must be readable. A '.' found before e also causes the following character to be inspected. |
- Returns
- The U32 result described by U32_atoi. No input-validation or overflow status is returned.
◆ U32_hextoi()
| BA_API U32 U32_hextoi |
( |
const char * |
s | ) |
|
Convert an unsigned hexadecimal string.
- Parameters
-
| [in] | s | NUL-terminated string containing at most eight hexadecimal digits (0-9, a-f or A-F), or NULL. Do not include a sign or a 0x prefix. |
- Returns
- The U32 value, or zero for NULL, an empty string or a string longer than eight characters. Zero is also a valid result. Callers must validate the character set themselves; malformed strings are not reliably rejected.
◆ U32_negate()
| BA_API U32 U32_negate |
( |
U32 |
n | ) |
|
Negate a 32-bit integer representation.
- Parameters
-
| [in] | n | Value to negate, interpreted as S32. The S32 minimum value must not be supplied, since its signed negation is not representable. |
- Returns
- The negated value represented as U32.
◆ U64_atoll()
| BA_API U64 U64_atoll |
( |
const char * |
s | ) |
|
Convert a decimal string to a 64-bit integer representation.
- Parameters
-
| [in] | s | NUL-terminated decimal string, optionally starting with '-'; NULL is allowed. No whitespace or '+' prefix is accepted by this contract. The caller must provide valid digits and a value within the target range. |
- Returns
- The U64 value, or zero for NULL or an empty string. A negative value is returned in its unsigned representation; use S64_atoll for an S64 result.
- Note
- This helper does not validate digits or report overflow. Zero is also a valid conversion result and is not a distinguishable error indication.
◆ U64_atoll2()
| BA_API U64 U64_atoll2 |
( |
const char * |
s, |
|
|
const char * |
e |
|
) |
| |
Convert a bounded decimal character sequence to a 64-bit representation.
- Parameters
-
| [in] | s | Start of the sequence, or NULL to return zero. If non-NULL, s must be readable even when the sequence is empty. |
| [in] | e | One past the last character, in the same buffer as s, with e >= s. Ignored when s is NULL. A terminating NUL is not required. |
- Returns
- The U64 representation of the converted integer, or zero for NULL or an empty sequence. The same digit, sign and range requirements as U64_atoll apply. This function does not round decimal fractions.