SSumHarrier
Workflows

Coding workflows · Compensated floating-point sums

03
Built around your work

A concrete starting point

Sum at most 1000 finite numbers of magnitude at most 1e100 with a compensation term. Check cancellation around a small addend and empty input, rejecting Boolean and non-finite values before summation.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Compensated floating-point sums

A concrete starting point
def compensated_sum(values):
    values = tuple(values)
    if len(values) > 1000 or any(type(v) not in (int, float) or
                                not -1e100 <= v <= 1e100 for v in values):
        raise ValueError("values.range")
    total = correction = 0.0
    for value in values:
        value = float(value)
        next_total = total + value
        correction += ((total - next_total) + value if abs(total) >= abs(value)
                       else (value - next_total) + total)
        total = next_total
    return total + correction

The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.

AI coding workspace

Your next change starts here.

Get the Windows app ↗