This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients Jeffrey.Kintscher, mark.dickinson, pablogsal, rhettinger, tim.peters, veky
Date 2020-08-06.11:24:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Here's code to illustrate the idea. It doesn't yet handle zeros, infinities or nans; that support would need to be added.

import math

def fprod(numbers):
    # Product of numbers, avoiding intermediate underflow and overflow.
    # Does not handle zeros, infinities or nans

    # Running product is acc_m * 2**acc_e
    acc_m, acc_e = float.fromhex("1p1000"), -1000

    count = 0
    for number in numbers:
        m, e = math.frexp(number)
        acc_m *= m
        acc_e += e
        if count == 1000:
            if acc_m < 1.0:
                acc_m = math.ldexp(acc_m, 1000)
                acc_e -= 1000
            count = 0

    return math.ldexp(acc_m, acc_e)
Date User Action Args
2020-08-06 11:24:43mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, rhettinger, veky, pablogsal, Jeffrey.Kintscher
2020-08-06 11:24:43mark.dickinsonsetmessageid: <>
2020-08-06 11:24:43mark.dickinsonlinkissue41458 messages
2020-08-06 11:24:42mark.dickinsoncreate