top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Floating point minimum and maximum exponent values in Python

+1 vote
72 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, 
radix=2, rounds=1)

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 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes
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 by Salil Agrawal
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[2]))
        return 1;
    return abs(atoi(argv[1])) / atoi(argv[2]);
}
+3 votes

Using fprintf() print a single floating point number right-justified in a field of 20 spaces, no leading zeros, and 4 decimal places. The destination should be stderr and the variable is called num.


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...