top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Floating point minimum and maximum exponent values in Python

+1 vote
490 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 LinkedIn 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?

0 votes

I'm working on association analysis on my dataset that consist majorly of categorical features and I'm using Cramers' V and Theils U statistical measures for showcasing the association metrics.

I have 2 questions related to the same :

If there are some missing values in some of the columns in my dataset, how should I handle them while calculation Cramers' V and theils u metrics? Shall I replace the missing value with some dummy value?
Note: I'm using python's python library for the calculation of both the metrics.

dython.nominal.cramers_v(data[field1],data[field2]) and dython.nominal.theils_u(data[field1],data[field2])

If I have a column name like "Task Creation Date" that consists of DateTime values. How can I include this field as part of my association analysis? Does Cramers' V and Theils U consider date values as input ? or some conversion is required?

Any help would be much appreciated.

–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]);
}
...