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

float.as_integer_ratio() needs to return fraction in lowest terms #46280

Closed
rhettinger opened this issue Feb 1, 2008 · 2 comments
Closed

float.as_integer_ratio() needs to return fraction in lowest terms #46280

rhettinger opened this issue Feb 1, 2008 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@rhettinger
Copy link
Contributor

BPO 1996
Nosy @rhettinger
Files
  • tmp_float_conv.py: Pure python equivalent
  • 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 2008-02-01.21:31:00.066>
    created_at = <Date 2008-02-01.19:45:01.194>
    labels = ['interpreter-core']
    title = 'float.as_integer_ratio() needs to return fraction in lowest terms'
    updated_at = <Date 2008-02-01.21:31:00.065>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2008-02-01.21:31:00.065>
    actor = 'rhettinger'
    assignee = 'jyasskin'
    closed = True
    closed_date = <Date 2008-02-01.21:31:00.066>
    closer = 'rhettinger'
    components = ['Interpreter Core']
    creation = <Date 2008-02-01.19:45:01.194>
    creator = 'rhettinger'
    dependencies = []
    files = ['9344']
    hgrepos = []
    issue_num = 1996
    keywords = []
    message_count = 2.0
    messages = ['61975', '61978']
    nosy_count = 2.0
    nosy_names = ['rhettinger', 'jyasskin']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1996'
    versions = ['Python 2.6']

    @rhettinger
    Copy link
    Contributor Author

    Just before the sign bit is restored, add code with the following effect:

        while not top&1:
            top >>= 1
            e += 1

    Tests:
    math.pi --> (884279719003555, 281474976710656)
    7.5 --> (15, 2)
    0.875 --> (7, 8)

    @rhettinger rhettinger added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Feb 1, 2008
    @rhettinger
    Copy link
    Contributor Author

    Fixed in revision 60511.

    @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

    1 participant