logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

intN_t, int8_t, int16_t, int32_t, int64_t, uintN_t, uint8_t, uint16_t, uint32_t, uint64_t - fixed-width

Description

intN_t are signed integer types of a fixed width of exactly N bits, N being the value  specified  in  its
       type  name.   They  are be capable of storing values in the range [INTN_MIN, INTN_MAX], substituting N by
       the appropriate number.

       uintN_t are unsigned integer types of a fixed width of exactly N bits, N being the value specified in its
       type name.  They are capable of storing values in  the  range  [0,  UINTN_MAX],  substituting  N  by  the
       appropriate number.

       According  to  POSIX, [u]int8_t, [u]int16_t, and [u]int32_t are required; [u]int64_t are only required in
       implementations that provide integer types with width 64; and all other types of this form are optional.

       The macros [U]INTN_WIDTH expand to the width in bits of these types (N).

       The macros [U]INTN_MAX expand to the maximum value that these types can hold.

       The macros INTN_MIN expand to the minimum value that these types can hold.

       The macros [U]INTN_C() expand their argument to an integer constant of type [u]intN_t.

       The length modifiers for the [u]intN_t types for the printf(3) family of functions are expanded by macros
       of the forms PRIdN, PRIiN, PRIuN, and PRIxN (defined in <inttypes.h>); resulting for example in %"PRId64"
       or %"PRIi64" for printing int64_t values.  The length modifiers for the [u]intN_t types for the  scanf(3)
       family  of  functions  are  expanded  by  macros of the forms SCNdN, SCNiN, SCNuN, and SCNxN, (defined in
       <inttypes.h>); resulting for example in %"SCNu8" or %"SCNx8" for scanning uint8_t values.

History

       C99, POSIX.1-2001.

       The [U]INTN_WIDTH macros were added in C23.

Library

       Standard C library (libc)

Name

       intN_t,  int8_t,  int16_t, int32_t, int64_t, uintN_t, uint8_t, uint16_t, uint32_t, uint64_t - fixed-width
       basic integer types

Notes

       The following header also provides these types: <inttypes.h>.  <arpa/inet.h> also provides  uint16_t  and
       uint32_t.

See Also

intmax_t(3type), intptr_t(3type), printf(3)

Linux man-pages 6.9.1                              2024-05-02                                      intN_t(3type)

Standards

       C11, POSIX.1-2008.

Synopsis

#include<stdint.h>typedef /* ... */ int8_t;typedef /* ... */ int16_t;typedef /* ... */ int32_t;typedef /* ... */ int64_t;typedef /* ... */ uint8_t;typedef /* ... */ uint16_t;typedef /* ... */ uint32_t;typedef /* ... */ uint64_t;#defineINT8_WIDTH8#defineINT16_WIDTH16#defineINT32_WIDTH32#defineINT64_WIDTH64#defineUINT8_WIDTH8#defineUINT16_WIDTH16#defineUINT32_WIDTH32#defineUINT64_WIDTH64#defineINT8_MAX     /*  2**(INT8_WIDTH - 1) - 1   */
       #defineINT16_MAX    /*  2**(INT16_WIDTH - 1) - 1  */
       #defineINT32_MAX    /*  2**(INT32_WIDTH - 1) - 1  */
       #defineINT64_MAX    /*  2**(INT64_WIDTH - 1) - 1  */

       #defineINT8_MIN     /*  - 2**(INT8_WIDTH - 1)     */
       #defineINT16_MIN    /*  - 2**(INT16_WIDTH - 1)    */
       #defineINT32_MIN    /*  - 2**(INT32_WIDTH - 1)    */
       #defineINT64_MIN    /*  - 2**(INT64_WIDTH - 1)    */

       #defineUINT8_MAX    /*  2**INT8_WIDTH - 1         */
       #defineUINT16_MAX   /*  2**INT16_WIDTH - 1        */
       #defineUINT32_MAX   /*  2**INT32_WIDTH - 1        */
       #defineUINT64_MAX   /*  2**INT64_WIDTH - 1        */

       #defineINT8_C(c)c## /* ... */
       #defineINT16_C(c)c## /* ... */
       #defineINT32_C(c)c## /* ... */
       #defineINT64_C(c)c## /* ... */

       #defineUINT8_C(c)c## /* ... */
       #defineUINT16_C(c)c## /* ... */
       #defineUINT32_C(c)c## /* ... */
       #defineUINT64_C(c)c## /* ... */

See Also