Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys.maxfloat patch #45875

Closed
tiran opened this issue Dec 1, 2007 · 9 comments
Closed

sys.maxfloat patch #45875

tiran opened this issue Dec 1, 2007 · 9 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@tiran
Copy link
Member

tiran commented Dec 1, 2007

BPO 1534
Nosy @gvanrossum, @mdickinson, @tiran
Files
  • trunk_maxfloat.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2007-12-01.11:24:11.400>
    created_at = <Date 2007-12-01.01:22:16.602>
    labels = ['interpreter-core']
    title = 'sys.maxfloat patch'
    updated_at = <Date 2008-01-06.22:29:44.719>
    user = 'https://github.com/tiran'

    bugs.python.org fields:

    activity = <Date 2008-01-06.22:29:44.719>
    actor = 'admin'
    assignee = 'none'
    closed = True
    closed_date = <Date 2007-12-01.11:24:11.400>
    closer = 'christian.heimes'
    components = ['Interpreter Core']
    creation = <Date 2007-12-01.01:22:16.602>
    creator = 'christian.heimes'
    dependencies = []
    files = ['8840']
    hgrepos = []
    issue_num = 1534
    keywords = ['patch']
    message_count = 9.0
    messages = ['58037', '58038', '58041', '58051', '58053', '58054', '58055', '58062', '58075']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'mark.dickinson', 'christian.heimes']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1534'
    versions = ['Python 2.6', 'Python 3.0']

    @tiran
    Copy link
    Member Author

    tiran commented Dec 1, 2007

    Currently Python has no information about the maximum and minimum value
    of a float. The patch adds a dict with all important information to sys:

    >>> pprint.pprint(sys.maxfloat)
    {'dig': 15,
     'epsilon': 2.2204460492503131e-16,
     'mant_dig': 53,
     'max': 1.7976931348623157e+308,
     'max_10_exp': 308,
     'max_exp': 1024,
     'min': 2.2250738585072014e-308,
     'min_10_exp': -307,
     'min_exp': -1021,
     'radix': 2,
     'rounds': 1}

    The patch compiles on Linux and Windows.

    @tiran tiran added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Dec 1, 2007
    @gvanrossum
    Copy link
    Member

    I'd suggest giving it a different name, maybe float_info. sys.maxfloat
    suggests the value is a float, like sys.maxint and sys.maxunicode.

    @tiran
    Copy link
    Member Author

    tiran commented Dec 1, 2007

    Applied in r59254.

    I've moved the code to floatobject.c/h and added PyFloat_GetMax() and
    PyFloat_GetMin(), too. The intobject.c file has a similar function.

    @tiran tiran closed this as completed Dec 1, 2007
    @mdickinson
    Copy link
    Member

    A (probably stupid) question: what's supposed to happen on platforms that
    don't define things like DBL_MAX_10_EXP, which isn't part of ANSI C89? Or
    are there no such platforms?

    @tiran
    Copy link
    Member Author

    tiran commented Dec 1, 2007

    I've checked all major platforms before committing the patch. They all
    have a float.h with the information available. Do you know of a platform
    where this information isn't available? I could add a lot of #ifdef but
    I don't feel like bloating the code unless it is necessary.

    @mdickinson
    Copy link
    Member

    No, I don't know of any platforms that don't define these constants.

    @mdickinson
    Copy link
    Member

    And it looks as though DBL_MAX_10_EXP *is* part of ANSI C anyway... I
    shouldn't have assumed that just because it's not in Kernighan and Ritchie
    (2nd edition) it doesn't exist... Apologies.

    @tiran
    Copy link
    Member Author

    tiran commented Dec 1, 2007

    Thanks for checking it out for me! Do you have a reliable online source
    for the ANSI C89 standard? I'm usually using the GNU C Library docs but
    the site doesn't list what's available in C89.

    @mdickinson
    Copy link
    Member

    The site that persuaded me about DBL_MAX_10_EXP was

    http://www.schweikhardt.net/identifiers.html

    Googling 'C89 draft' also turns up some potentially useful stuff.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants