Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would you set a variable to the largest number possible in C?

Tags:

How would you set a variable to equal infinity (or any guaranteed largest number value) in C?

like image 881
Sam Avatar asked Feb 16 '10 15:02

Sam


People also ask

What is the largest int in C?

Value of INT_MAX is +2147483647. Value of INT_MIN is -2147483648.

Which variable type will store the largest number?

Int. The int data type can store whole numbers from -2147483648 to 2147483647. In general, and in our tutorial, the int data type is the preferred data type when we create variables with a numeric value.


1 Answers

#include <limits.h> int x = INT_MAX; 

EDIT: answered before the questioner clarified, I was just guessing what type they wanted.

like image 84
dubiousjim Avatar answered Oct 11 '22 01:10

dubiousjim