sortByExp<FpType extends FloatingPoint> static method
- (FpType, FpType) toSort
Sort two FloatingPoints and swap them if necessary so that the one the larger exponent is the first element in the returned tuple.
Implementation
static ({(FpType larger, FpType smaller) sorted, Logic didSwap})
sortByExp<FpType extends FloatingPoint>((FpType, FpType) toSort) {
final ae = toSort.$1.exponent;
final be = toSort.$2.exponent;
final doSwap = (ae.lt(be) | ((ae.eq(be)) & toSort.$1.sign)).named('doSwap');
final swapped = swap(doSwap, toSort);
final larger =
(swapped.$1.clone(name: 'larger')..gets(swapped.$1)) as FpType;
final smaller =
(swapped.$2.clone(name: 'smaller')..gets(swapped.$2)) as FpType;
return (sorted: (larger, smaller), didSwap: doSwap);
}