Embedded Artistry Framework
Embedded Systems C++ Framework
Functions
strtoull.c File Reference
#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
Include dependency graph for strtoull.c:

Functions

unsigned long long strtoull (const char *__restrict nptr, char **__restrict endptr, int base)
 Interprets an unsigned long long value in a byte string pointed to by str. More...
 

Function Documentation

◆ strtoull()

unsigned long long strtoull ( const char *__restrict  str,
char **__restrict  str_end,
int  base 
)

Interprets an unsigned long long value in a byte string pointed to by str.

Interprets an unsigned long long value in a byte string pointed to by str. Discards any whitespace characters (as identified by calling

See also
isspace()) until the first non-whitespace character is found, then takes as many characters as possible to form a valid base-n (where n=base) long number representation and converts them to an unsigned long long value. The valid long value consists of the following parts:
 1) (optional) plus or minus sign
 2) (optional) prefix (0) indicating octal base (applies only when the base is 8 or ​0​)
 3) (optional) prefix (0x or 0X) indicating hexadecimal base (applies only when the base is
16 or ​0​) 4) a sequence of digits

The set of valid values for base is {0,2,3,...,36}. The set of valid digits for base-2 integers is {0,1}, for base-3 integers is {0,1,2}, and so on. For bases larger than 10, valid digits include alphabetic characters, starting from Aa for base-11 integer, to Zz for base-36 integer. The case of the characters is ignored.

If the value of base is ​0​, the numeric base is auto-detected: if the prefix is 0, the base is octal, if the prefix is 0x or 0X, the base is hexadecimal, otherwise the base is decimal.

If the minus sign was part of the input sequence, the numeric value calculated from the sequence of digits is negated as if by unary minus in the result type.

If the str is empty or does not have the expected form, no conversion is performed, and (if str_end is not NULL) the value of str is stored in the object pointed to by str_end.

Parameters
strpointer to the null-terminated byte string to be interpreted
str_endpointer to a pointer to character.
basebase of the interpreted integer value
Returns
returns the result of the conversion, unless the value would underflow or overflow. If the converted value falls out of range of corresponding return type, a range error occurs (setting errno to ERANGE) and LONG_MAX, LONG_MIN, LLONG_MAX or LLONG_MIN is returned. If no conversion can be performed, ​0​ is returned.

References isspace(), NULL, s, and ULLONG_MAX.

Referenced by strtoull_test().

Here is the caller graph for this function: