Can anyone tell me the upper and lower limits for the basic data types (int, float, long, etc.)?

ie. Ints have upper limits of 32000ish if I'm not mistaken, but I need the exact numbers.

Thanks a bunch...

Printable View

- 01-26-2003JTtheCPPgoddata type limits
Can anyone tell me the upper and lower limits for the basic data types (int, float, long, etc.)?

ie. Ints have upper limits of 32000ish if I'm not mistaken, but I need the exact numbers.

Thanks a bunch... - 01-26-2003Hammer
Look in limits.h

- 01-26-2003JTtheCPPgodum
That didn't seem to work.

I'm not terribly advanced and I have trouble reading what the libraries say.

And it also didn't look like it had all the data types I needed (if it did, they had different names)

anybody else? - 01-26-2003Eibro
Look in either <limits> or <limits.h>

Here's an example using limits:

Code:`#include <iostream>`

#include <limits>

int main(int argc, char** argv)

{

using namespace std;

cout << "\nsigned int max: " << std::numeric_limits<signed int>::max();

cout << "\nsigned int min: " << std::numeric_limits<signed int>::min();

cout << "\nchar max: " << std::numeric_limits<char>::max();

cout << "\nchar min: " << std::numeric_limits<char>::min();

return 0;

}

- 01-26-2003JTtheCPPgod
I'm afraid I still don't understand.

I don't want a program that produces these values.

I don't even have a copy of Visual Studio herea t home.

I just need the numbers... - 01-26-2003Cela
>>I just need the numbers...

The numbers will be different for different machines. You have to use either <limits> or <climits>/<limits.h> for any measure of portability. If anyone gives you just the numbers and doesn't say "at least" then they're wrong. :-) - 01-26-2003Eibro
It's implementation dependant.

Depending on what system you're on, the size of different types vary.

edit: Beaten :( - 01-26-2003nag
For a 16 bit machine it is

unsigned int=2^16 -1 (2 to the power 16) =65535

for a 32 bit machine

unsigned int=2^32 -1 =4294967295

for signed int value divide it by two

:):):)at the moment my calculkator is not working