Floating point minimum and maximum exponent values

Discussion in 'Python' started by Marco, Jul 16, 2013.

  1. Marco

    Marco Guest

    Hi all, 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...


    --
    Marco Buttu
    Marco, Jul 16, 2013
    #1
    1. Advertising

  2. On Tue, Jul 16, 2013 at 9:43 PM, Marco <> wrote:
    > Hi all, 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...


    Piece of extreme oddity, this.

    >>> help(sys.float_info)

    .... lots of other info ...
    | max_exp
    | DBL_MAX_EXP -- maximum int e such that radix**(e-1) is representable
    |
    | min_exp
    | DBL_MIN_EXP -- minimum int e such that radix**(e-1) is a
    normalized float
    ....

    So it's technically correct. Followup question: Why is it off by one?

    ChrisA
    Chris Angelico, Jul 16, 2013
    #2
    1. Advertising

  3. 16.07.13 15:04, Chris Angelico напиÑав(ла):
    > Piece of extreme oddity, this.
    >
    >>>> help(sys.float_info)

    > ... lots of other info ...
    > | max_exp
    > | DBL_MAX_EXP -- maximum int e such that radix**(e-1) is representable
    > |
    > | min_exp
    > | DBL_MIN_EXP -- minimum int e such that radix**(e-1) is a
    > normalized float
    > ...
    >
    > So it's technically correct. Followup question: Why is it off by one?


    sys.float_info.max == sys.float_info.radix**sys.float_info.max_exp -
    sys.float_info.radix**(sys.float_info.max_exp-sys.float_info.mant_dig)
    Serhiy Storchaka, Jul 16, 2013
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    6
    Views:
    380
  2. Ioannis Vranos
    Replies:
    13
    Views:
    470
    James Kanze
    Mar 10, 2008
  3. Ioannis Vranos

    Minimum sizes of integral and floating point types

    Ioannis Vranos, Mar 8, 2008, in forum: C Programming
    Replies:
    9
    Views:
    325
    Richard Heathfield
    Mar 9, 2008
  4. ceycey
    Replies:
    5
    Views:
    505
  5. Saraswati lakki
    Replies:
    0
    Views:
    1,283
    Saraswati lakki
    Jan 6, 2012
Loading...

Share This Page