## For Programmers Numeric Type Ranges

The range of the numeric types depends on the system running them, unless, of course, they're running under Java. This means that, in Jython, Integer is implemented with Java Int, and Float is implemented with Java Double. The reverse is true in mython: Integer is implemented with C Long, and Float with C Double.Long has an unlimited range in both CPython and JytSon. Unlike in C, in Java Integer always holds the same range of values.

You often need to know tlse biggest on amallest Integer or Float type, but trying to remember this information is difficult. I'm going to show you an interactive session that will give you this information when you need it. Remember that Float in Python equVBs to Java Double, so the first thing to do is import classDouble from the java.lang package.

>>> from java.lang import Double

We could instead do a dir on Double to) see its MAX_VALU E and MIN_VALU E attributes.

['MAX_VALUE', 'MIN_VALUE', 'NEGATIVE_INFINITY', 'NaN',

'POSITIVE_INFINITY', 'TYPE', '_doc__', '_init_', '_module_',

'compareTo', 'doubleToLongBits', 'infinite', 'isInfinite', 'isNaN', 'longBitsToDouble', 'naN', 'parseDouble', 'toString', 'valueOf']

Here's how to access the largest and smalle st Float, respectively :

>>> Double.MAX_VALUE 1.7976931348623157E308

Now we'll do the same thing for the biggest and smallest Integer.

>>> from java.lang import Integer >>> max = Integer.MAX_VALUE >>> min = Integer.MIN_VALUE >>> max, min

(2147483647, -2147483648)