Next: , Previous: , Up: Integer Properties   [Contents][Index]


13.5.2 Integer Bounds

INT_BUFSIZE_BOUND (t) expands to an integer constant expression that is a bound on the size of the string representing an integer type or expression t in decimal notation, including the terminating null character and any leading - character. For example, if INT_STRLEN_BOUND (int) is 12, any value of type int can be represented in 12 bytes or less, including the terminating null. The bound is not necessarily tight.

Example usage:

#include <intprops.h>
#include <stdio.h>
int
int_strlen (int i)
{
  char buf[INT_BUFSIZE_BOUND (int)];
  return sprintf (buf, "%d", i);
}

INT_STRLEN_BOUND (t) expands to an integer constant expression that is a bound on the length of the string representing an integer type or expression t in decimal notation, including any leading - character. This is one less than INT_BUFSIZE_BOUND (t).

TYPE_MINIMUM (t) and TYPE_MAXIMUM (t) expand to integer constant expressions equal to the minimum and maximum values of the integer type t. These expressions are of the type t (or more precisely, the type t after integer promotions).

Example usage:

#include <stdint.h>
#include <sys/types.h>
#include <intprops.h>
int
in_off_t_range (intmax_t a)
{
  return TYPE_MINIMUM (off_t) <= a && a <= TYPE_MAXIMUM (off_t);
}