[Univ of Cambridge] [Dept of Engineering]
next up previous contents
Next: Performance Up: More C++ Previous: Casts

Limits

Use <climits> to access information on the system's limits. E.g. to check if a long variable can fit into a short you could try

long i;
if (i<numeric_limits<short>::min() || numeric_limits<short>::max() <i)
     cout << i << "cannot fit into a short"



Tim Love
2001-07-05