adjustForAllocate

fun List<Percentage>.adjustForAllocate(tolerance: Double = TOLERANCE): List<Percentage>(source)

Adjust a list of Percentage to sum up to 100% if the difference is within the given tolerance. Useful when working with a list of Percentage calculated using floating-point arithmetic.

The difference is always added to the first list item.

Receiver

List

Return

A list of Percentage.

Parameters

tolerance

The difference tolerance. Defaults to 9E-14.

Throws

If the difference is not within the tolerance.