Large Integer Conversions

With the migration of UNIX systems to 64-bit CPUs, the C language now supports 64-bit integers. These data types are

  • long long int

  • unsigned long long int

or simply

  • long long

  • unsigned long long

With the appearance of these C data types comes the need to make conversions from strings to these 64-bit types.

Some UNIX platforms now support the strtoll(3) and strtoull(3) functions. Their synopsis is as follows:

#include <stdlib.h>

long long strtoll(const char *str, char **endptr, int base);

unsigned long long strtoull (const char *str, char **endptr, int base);

These functions work the same as their strtol(3) and strtoul(3) counterparts. The only difference is that you must use the macro LONGLONG_MAX or LONGLONG_MIN when ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.