   # Floating point minimum and maximum exponent values in Python

+1 vote
100 views

Why the maximum and minimum exp values are 1024 and -1021?:

`````` >>> sys.float_info
sys.float_info(max=1.7976931348623157e+308, max_exp=1024,
max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021,
min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16,
``````

The values (in double precision) 0 and 2047 are reserved for zero, infinity and NaN (in combination with the fraction), so I was expecting -1022 and 1023... posted Jul 16, 2013

``````help(sys.floatinfo)
... lots of other info ...
| maxexp
| DBLMAXEXP -- maximum int e such that radix(e-1) is representable
|
| minexp
| DBLMIN_EXP -- minimum int e such that radix(e-1) is a normalized float
`````` answer Jul 17, 2013
Similar Questions
+1 vote

I have an object (a variable) name, which gets its value from a PostgreSQL database via a SELECT statement, an it sometimes has special characters as ß, ä, ö...

Then I would like to insert that value into a table in a SQLite database. So I make a cursor cur on the table and prepare a SQL statement like this:

``````sql = 'insert into tbl values(?)'
cur.execute(sql, (name,))
``````

That ends up with the exception, for example,

``````UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6:  ordinal not in range(128)
``````

The "position 6" is exactly the position of the special character, ß in this case. What to do?

–1 vote

Determine the set of inputs that will lead to SIGFPE (floating point exception) being triggered in following C program?

``````#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
if(argc != 3 || !atoi(argv))
return 1;
return abs(atoi(argv)) / atoi(argv);
}
``````