+ 1

Is there a way to know maximum 'value'(not size) that a data type can hold??like long long int?

18th Jul 2018, 12:10 PM
THE GAMER
THE GAMER - avatar
5 Respostas
+ 1
It depend from the bit used to data type... if I remember correclty "long long" use 64bit... so 2^64 = 18446744073709551616 (very little ah? ahaha). But this long number is divided by 2, because exist positive and negative numbers ;) so +9223372036854775808 and -9223372036854775808!!! :)
18th Jul 2018, 12:25 PM
Yuri Biasi
Yuri Biasi - avatar
+ 1
to be very precise +9,223,372,036,854,775,807 and -9,223,372,036,854,775,808... but they are details :) (the positive number include the 0, so the tot-1!!)
18th Jul 2018, 12:28 PM
Yuri Biasi
Yuri Biasi - avatar
+ 1
try it and let me know if that's what you're looking for -> https://code.sololearn.com/cQi5v6w9rBov/#cpp other key of limits.h library are: CHAR_BIT = number of bits in a char SCHAR_MIN = minimum value for a signed char SCHAR_MAX = maximum value for a signed char UCHAR_MAX = maximum value for an unsigned char CHAR_MIN = minimum value for a char CHAR_MAX = maximum value for a char MB_LEN_MAX = maximum multibyte length of a character accross locales SHRT_MIN = minimum value for a short SHRT_MAX = maximum value for a short USHRT_MAX = maximum value for an unsigned short INT_MIN = minimum value for an int INT_MAX = maximum value for an int UINT_MAX = maximum value for an unsigned int LONG_MIN = minimum value for a long LONG_MAX = maximum value for a long ULONG_MAX = maximum value for an unsigned long LLONG_MIN = minimum value for a long long LLONG_MAX = maximum value for a long long ULLONG_MAX = maximum value for an unsigned long long
18th Jul 2018, 1:22 PM
Yuri Biasi
Yuri Biasi - avatar
+ 1
THANKS MAN!!!!!It works.... for ULLONG_MAX and LLONG_MAX anyway.😀I think the rest will work too.Thanks again!
18th Jul 2018, 2:44 PM
THE GAMER
THE GAMER - avatar
0
it's true,but I need to display the message "number out of bounds" if the number obtained after an operation say ' * ' can't be stored in a variable.Also it would be difficult to check it against such a large number (provided I "magically" remembered it!😅) hence a keyword that has it stored already would be really helpful!!!
18th Jul 2018, 12:52 PM
THE GAMER
THE GAMER - avatar