Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a LARGEST_INTEGER macro or something similar? (C) [duplicate]

Tags:

Possible Duplicates:
How would you set a variable to the largest number possible in C?
maximum value of int

I need to use the maximum integer value in my my code, but I don't want to explicitly write 4294967295. Is it defined somewhere?

like image 976
snakile Avatar asked Aug 29 '10 18:08

snakile


People also ask

What is the largest integer in Python?

value, which corresponds to 18,446,744,073,709,551,615 for the unsigned data type and ranges from -9,223,372,036,854,775,807 to 9,223,372,036,854,775,807 in the signed version.

How do you find the maximum int?

Values of INT_MAX and INT_MIN may vary from compiler to compiler. Following are typical values in a compiler where integers are stored using 32 bits. Value of INT_MAX is +2147483647. Value of INT_MIN is -2147483648.

How do you give a variable a maximum value in C++?

size_t size_max = -1; unsigned int uint_max = -1; unsigned long ulong_max = -1; assign the values SIZE_MAX , UINT_MAX and ULONG_MAX to the variables respectively.


2 Answers

INT_MAX (for int) or UINT_MAX (for unsigned int) defined in <limits.h>

like image 154
James McNellis Avatar answered Nov 19 '22 12:11

James McNellis


Use limits.h:

#include <limits.h>  int maximum = INT_MAX; 
like image 25
GManNickG Avatar answered Nov 19 '22 13:11

GManNickG