strtoul.c

The libc implementation

Author

Martin ‘Solar’ Baute

License

Public Domain

Functions

strtoul

unsigned long int strtoul(const char *s,
char **endptr,
int base)

Converts a string in s to an unsigned long.

A nonzero base can be supplied to force a specific radix.

endptr can be supplied in order to get a pointer to the remainder of the string.

Returns the value in the string if present, clamped to the maximum on overflow

Returns 0 if the string isn’t a number

Todo’s

These tests assume two-complement, but conversion should work

test “odd” overflow, i. e. base is not power of two

test “odd” overflow, i. e. base is not power of two

unsigned long int strtoul(const char *s,
char **endptr,
int base)
Converts a string in s to an unsigned long.