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


17.7.2 Integer Bounds

INT_BUFSIZE_BOUND (t) is 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_BUFSIZE_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) is 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) are integer constant expressions equal to the minimum and maximum values of the integer type t. These expressions are of the type t.

Example usage:

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