Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

numeric types — concept C23

Numeric types have implementation-dependent ranges and representations; use `limits.h`, `float.h`, or `stdint.h` types and check overflow before conversion and arithmetic.

Version: C23

Syntax

numeric types

Numeric types have implementation-dependent ranges and representations; use limits.h, float.h, or stdint.h types and check overflow before conversion and arithmetic.

Choose a type from range and meaning: size_t for object sizes, ptrdiff_t for pointer differences, and stdint.h types for fields requiring an exact width when the implementation provides them. Use matching format specifiers or PRI* macros.

Test INT_MIN, INT_MAX, SIZE_MAX, subnormal values, infinity, and NaN when supported. Signed addition may be undefined, unsigned arithmetic wraps modulo, and a signed/unsigned comparison may first convert a negative value to a large positive one.

Examples

#include <limits.h>
#include <stdio.h>

int main(void) { printf("%d\n", CHAR_BIT >= 8 && sizeof(long) >= sizeof(int)); return 0; }

Result

1

Numeric types have implementation-dependent ranges and representations; use `limits.h`, `float.h`, or `stdint.h` types and check overflow before conversion and arithmetic.

Sources