From cfa889e60d877ce760329cd62c76c3c65052c36b Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Sun, 21 Sep 2025 16:27:21 +0400 Subject: [PATCH 1/6] tests for target exponent --- .../LibDecimalFloatImplementation.sol | 282 +++++++++--------- ...oatImplementation.withTargetExponent.t.sol | 39 +++ 2 files changed, 183 insertions(+), 138 deletions(-) diff --git a/src/lib/implementation/LibDecimalFloatImplementation.sol b/src/lib/implementation/LibDecimalFloatImplementation.sol index f7ba8ede..9e38ad83 100644 --- a/src/lib/implementation/LibDecimalFloatImplementation.sol +++ b/src/lib/implementation/LibDecimalFloatImplementation.sol @@ -547,13 +547,9 @@ library LibDecimalFloatImplementation { } // Be careful to handle overflow. if (didOverflow) { - if (type(int256).max == exponentA) { - revert ExponentOverflow(signedCoefficientA, exponentA); - } - signedCoefficientA /= 10; signedCoefficientB /= 10; - exponentA++; + exponentA += 1; signedCoefficientA += signedCoefficientB; } else { signedCoefficientA = c; @@ -623,124 +619,128 @@ library LibDecimalFloatImplementation { view returns (int256, int256) { - { - int256 unmaximizedCoefficient = signedCoefficient; - int256 unmaximizedExponent = exponent; - (signedCoefficient, exponent) = maximizeFull(signedCoefficient, exponent); + unchecked { + { + int256 unmaximizedCoefficient = signedCoefficient; + int256 unmaximizedExponent = exponent; + (signedCoefficient, exponent) = maximizeFull(signedCoefficient, exponent); - if (signedCoefficient <= 0) { - if (signedCoefficient == 0) { - revert Log10Zero(); - } else { - revert Log10Negative(unmaximizedCoefficient, unmaximizedExponent); + if (signedCoefficient <= 0) { + if (signedCoefficient == 0) { + revert Log10Zero(); + } else { + revert Log10Negative(unmaximizedCoefficient, unmaximizedExponent); + } } } - } - - // all powers of 10 look like 1 with a different exponent - if (signedCoefficient == 1e76) { - return (exponent + 76, 0); - } - bool isAtLeastE76 = signedCoefficient >= 1e76; - - // This is a positive log. i.e. log(x) where x >= 1. - if (exponent >= (isAtLeastE76 ? -76 : -75)) { - int256 y1Coefficient; - int256 y2Coefficient; - int256 x1Coefficient; - int256 x2Coefficient; - // exact powers of 10 are already caught above. - // but e.g. 20 would be 2e76, -75 and true for isAtLeastE76 - // => adding exp 76 yields 1, which is the correct result. - // 200 would be 2e76, -74 and true for isAtLeastE76 - // => adding exp 76 yields 2, which is the correct result. - // however 90 would be 9e75, -74 and false for isAtLeastE76 - // => adding exp 75 yields 1, which is the correct result. - // 900 would be 9e75, -73 and false for isAtLeastE76 - // => adding exp 75 yields 2, which is the correct result. - int256 powerOfTen = exponent + int256(isAtLeastE76 ? int256(76) : int256(75)); - // Table lookup. - { - int256 scale = 1e72; - assembly ("memory-safe") { - //slither-disable-next-line divide-before-multiply - function lookupTableVal(tables, index) -> result { - // First byte of the data contract must be skipped. - let mainOffset := add(1, mul(div(index, 10), 2)) - mstore(0, 0) - extcodecopy(tables, 30, mainOffset, 2) - let mainTableVal := mload(0) - - result := and(mainTableVal, 0x7FFF) - // Skip first byte of data contract then 1820 bytes - // of the log tables. - let smallTableOffset := 1821 - if iszero(iszero(and(mainTableVal, 0x8000))) { - // Small table is half the size of the main - // table. - smallTableOffset := add(smallTableOffset, 910) + // all powers of 10 look like 1 with a different exponent + if (signedCoefficient == 1e76) { + return (exponent + 76, 0); + } + bool isAtLeastE76 = signedCoefficient >= 1e76; + + // This is a positive log. i.e. log(x) where x >= 1. + if (exponent >= (isAtLeastE76 ? -76 : -75)) { + int256 y1Coefficient; + int256 y2Coefficient; + int256 x1Coefficient; + int256 x2Coefficient; + // exact powers of 10 are already caught above. + // but e.g. 20 would be 2e76, -75 and true for isAtLeastE76 + // => adding exp 76 yields 1, which is the correct result. + // 200 would be 2e76, -74 and true for isAtLeastE76 + // => adding exp 76 yields 2, which is the correct result. + // however 90 would be 9e75, -74 and false for isAtLeastE76 + // => adding exp 75 yields 1, which is the correct result. + // 900 would be 9e75, -73 and false for isAtLeastE76 + // => adding exp 75 yields 2, which is the correct result. + int256 powerOfTen = exponent + int256(isAtLeastE76 ? int256(76) : int256(75)); + + // Table lookup. + { + int256 scale = 1e72; + assembly ("memory-safe") { + //slither-disable-next-line divide-before-multiply + function lookupTableVal(tables, index) -> result { + // First byte of the data contract must be skipped. + let mainOffset := add(1, mul(div(index, 10), 2)) + mstore(0, 0) + extcodecopy(tables, 30, mainOffset, 2) + let mainTableVal := mload(0) + + result := and(mainTableVal, 0x7FFF) + // Skip first byte of data contract then 1820 bytes + // of the log tables. + let smallTableOffset := 1821 + if iszero(iszero(and(mainTableVal, 0x8000))) { + // Small table is half the size of the main + // table. + smallTableOffset := add(smallTableOffset, 910) + } + + mstore(0, 0) + extcodecopy( + tables, 31, add(smallTableOffset, add(mul(div(index, 100), 10), mod(index, 10))), 1 + ) + result := add(result, mload(0)) } - mstore(0, 0) - extcodecopy(tables, 31, add(smallTableOffset, add(mul(div(index, 100), 10), mod(index, 10))), 1) - result := add(result, mload(0)) - } - - // Need to increase the scale by one OOM here so that the - // signed coefficient has 4 digits always, to make it - // easy to calculate the idx. - if isAtLeastE76 { scale := mul(scale, 10) } - - // Truncate the signed coefficient to what we can look - // up in the table. - // Slither false positive because the truncation is - // deliberate here. - //slither-disable-next-line divide-before-multiply - x1Coefficient := div(signedCoefficient, scale) - let idx := sub(x1Coefficient, 1000) - x1Coefficient := mul(x1Coefficient, scale) - // Technically we only need to do this if we need to - // interpolate but it's cheaper to just do an `add` - // unconditionally than pay for an `if` and often also - // do the `add`. - x2Coefficient := add(x1Coefficient, scale) - - // If we don't bring the scale back down here we can get - // overflows when multiplying the output of the lookups. - // We are reusing the same scale variable to avoid a - // compiler stack overflow. - // Slither false positive here, this division is simply - // the inverse of the mul above. - //slither-disable-next-line divide-before-multiply - if isAtLeastE76 { scale := div(scale, 10) } - - y1Coefficient := mul(scale, lookupTableVal(tablesDataContract, idx)) - // Only do the second lookup if we expect interpolation - // to need it. - if iszero(eq(x1Coefficient, signedCoefficient)) { - y2Coefficient := mul(scale, lookupTableVal(tablesDataContract, add(idx, 1))) + // Need to increase the scale by one OOM here so that the + // signed coefficient has 4 digits always, to make it + // easy to calculate the idx. + if isAtLeastE76 { scale := mul(scale, 10) } + + // Truncate the signed coefficient to what we can look + // up in the table. + // Slither false positive because the truncation is + // deliberate here. + //slither-disable-next-line divide-before-multiply + x1Coefficient := div(signedCoefficient, scale) + let idx := sub(x1Coefficient, 1000) + x1Coefficient := mul(x1Coefficient, scale) + // Technically we only need to do this if we need to + // interpolate but it's cheaper to just do an `add` + // unconditionally than pay for an `if` and often also + // do the `add`. + x2Coefficient := add(x1Coefficient, scale) + + // If we don't bring the scale back down here we can get + // overflows when multiplying the output of the lookups. + // We are reusing the same scale variable to avoid a + // compiler stack overflow. + // Slither false positive here, this division is simply + // the inverse of the mul above. + //slither-disable-next-line divide-before-multiply + if isAtLeastE76 { scale := div(scale, 10) } + + y1Coefficient := mul(scale, lookupTableVal(tablesDataContract, idx)) + // Only do the second lookup if we expect interpolation + // to need it. + if iszero(eq(x1Coefficient, signedCoefficient)) { + y2Coefficient := mul(scale, lookupTableVal(tablesDataContract, add(idx, 1))) + } } } - } - (signedCoefficient, exponent) = unitLinearInterpolation( - x1Coefficient, - signedCoefficient, - x2Coefficient, - exponent, - y1Coefficient, - y2Coefficient, - LOG10_Y_EXPONENT - ); - return add(signedCoefficient, exponent, powerOfTen, 0); - } - // This is a negative log. i.e. log(x) where 0 < x < 1. - // log(x) = -log(1/x) - else { - (signedCoefficient, exponent) = inv(signedCoefficient, exponent); - (signedCoefficient, exponent) = log10(tablesDataContract, signedCoefficient, exponent); - return minus(signedCoefficient, exponent); + (signedCoefficient, exponent) = unitLinearInterpolation( + x1Coefficient, + signedCoefficient, + x2Coefficient, + exponent, + y1Coefficient, + y2Coefficient, + LOG10_Y_EXPONENT + ); + return add(signedCoefficient, exponent, powerOfTen, 0); + } + // This is a negative log. i.e. log(x) where 0 < x < 1. + // log(x) = -log(1/x) + else { + (signedCoefficient, exponent) = inv(signedCoefficient, exponent); + (signedCoefficient, exponent) = log10(tablesDataContract, signedCoefficient, exponent); + return minus(signedCoefficient, exponent); + } } } @@ -760,32 +760,36 @@ library LibDecimalFloatImplementation { view returns (int256, int256) { - if (signedCoefficient < 0) { - (signedCoefficient, exponent) = minus(signedCoefficient, exponent); - (signedCoefficient, exponent) = pow10(tablesDataContract, signedCoefficient, exponent); - return inv(signedCoefficient, exponent); - } + unchecked { + if (signedCoefficient < 0) { + (signedCoefficient, exponent) = minus(signedCoefficient, exponent); + (signedCoefficient, exponent) = pow10(tablesDataContract, signedCoefficient, exponent); + return inv(signedCoefficient, exponent); + } - // Table lookup. - (int256 characteristicCoefficient, int256 mantissaCoefficient) = - characteristicMantissa(signedCoefficient, exponent); - int256 characteristicExponent = exponent; - { - (int256 idx, bool interpolate, int256 scale) = mantissa4(mantissaCoefficient, exponent); - (int256 y1Coefficient, int256 y2Coefficient) = - lookupAntilogTableY1Y2(tablesDataContract, uint256(idx), interpolate); - if (interpolate) { - (signedCoefficient, exponent) = unitLinearInterpolation( - idx * scale, mantissaCoefficient, (idx + 1) * scale, exponent, y1Coefficient, y2Coefficient, -4 - ); - } else { - signedCoefficient = y1Coefficient; - exponent = -4; + // Table lookup. + (int256 characteristicCoefficient, int256 mantissaCoefficient) = + characteristicMantissa(signedCoefficient, exponent); + int256 characteristicExponent = exponent; + { + (int256 idx, bool interpolate, int256 scale) = mantissa4(mantissaCoefficient, exponent); + (int256 y1Coefficient, int256 y2Coefficient) = + lookupAntilogTableY1Y2(tablesDataContract, uint256(idx), interpolate); + if (interpolate) { + (signedCoefficient, exponent) = unitLinearInterpolation( + idx * scale, mantissaCoefficient, (idx + 1) * scale, exponent, y1Coefficient, y2Coefficient, -4 + ); + } else { + signedCoefficient = y1Coefficient; + exponent = -4; + } } - } - return - (signedCoefficient, 1 + exponent + withTargetExponent(characteristicCoefficient, characteristicExponent, 0)); + return ( + signedCoefficient, + 1 + exponent + withTargetExponent(characteristicCoefficient, characteristicExponent, 0) + ); + } } /// @return signedCoefficient The maximized signed coefficient. @@ -965,7 +969,9 @@ library LibDecimalFloatImplementation { return signedCoefficient; } else if (targetExponent > exponent) { int256 exponentDiff = targetExponent - exponent; - if (exponentDiff > 76 || exponentDiff < 0) { + // exponentDiff can overflow if targetExponent is sufficiently + // positive and exponent is sufficiently negative. + if (exponentDiff > 76 || exponentDiff <= 0) { return (MAXIMIZED_ZERO_SIGNED_COEFFICIENT); } diff --git a/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol b/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol index d9984cc5..84cb7681 100644 --- a/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol +++ b/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol @@ -109,4 +109,43 @@ contract LibDecimalFloatImplementationWithTargetExponentTest is Test { checkWithTargetExponent(type(int256).min, 0, 1, type(int256).min / 10); checkWithTargetExponent(type(int256).max, 0, 1, type(int256).max / 10); } + + function testWithTargetExponentExponentEqual(int256 signedCoefficient, int256 exponent) external pure { + int256 actualSignedCoefficient = + LibDecimalFloatImplementation.withTargetExponent(signedCoefficient, exponent, exponent); + assertEq(actualSignedCoefficient, signedCoefficient, "signedCoefficient"); + } + + function testWithTargetExponentTargetMoreThan76Larger( + int256 signedCoefficient, + int256 exponent, + int256 targetExponent + ) external pure { + targetExponent = bound(targetExponent, type(int256).min + 77, type(int256).max); + exponent = bound(exponent, type(int256).min, targetExponent - 77); + + int256 actualSignedCoefficient = + LibDecimalFloatImplementation.withTargetExponent(signedCoefficient, exponent, targetExponent); + assertEq(actualSignedCoefficient, 0, "signedCoefficient"); + } + + function testWithTargetExponentMaxOverflow(int256 signedCoefficient) external pure { + int256 actualSignedCoefficient = + LibDecimalFloatImplementation.withTargetExponent(signedCoefficient, type(int256).min, type(int256).max); + assertEq(actualSignedCoefficient, 0, "signedCoefficient"); + } + + function testWithTargetExponentScaleDown(int256 signedCoefficient, int256 exponent, int256 targetExponentDiff) + external + pure + { + targetExponentDiff = bound(targetExponentDiff, int256(1), int256(76)); + exponent = bound(exponent, type(int256).min, type(int256).max - targetExponentDiff); + int256 targetExponent = exponent + targetExponentDiff; + + int256 actualSignedCoefficient = + LibDecimalFloatImplementation.withTargetExponent(signedCoefficient, exponent, targetExponent); + int256 expectedSignedCoefficient = signedCoefficient / int256(10 ** uint256(targetExponentDiff)); + assertEq(actualSignedCoefficient, expectedSignedCoefficient, "signedCoefficient"); + } } From f7be69e61c65ab8acaa107eb5e1d313d525c03b4 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Sun, 21 Sep 2025 16:34:02 +0400 Subject: [PATCH 2/6] fuzz target exponent --- ...oatImplementation.withTargetExponent.t.sol | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol b/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol index 84cb7681..1b399d06 100644 --- a/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol +++ b/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol @@ -148,4 +148,60 @@ contract LibDecimalFloatImplementationWithTargetExponentTest is Test { int256 expectedSignedCoefficient = signedCoefficient / int256(10 ** uint256(targetExponentDiff)); assertEq(actualSignedCoefficient, expectedSignedCoefficient, "signedCoefficient"); } + + function testWithTargetExponentScaleUpLargeDiffRevert( + int256 signedCoefficient, + int256 exponent, + int256 targetExponent + ) external { + exponent = bound(exponent, type(int256).min + 77, type(int256).max); + targetExponent = bound(targetExponent, type(int256).min, exponent - 77); + + vm.expectRevert( + abi.encodeWithSelector(WithTargetExponentOverflow.selector, signedCoefficient, exponent, targetExponent) + ); + this.withTargetExponentExternal(signedCoefficient, exponent, targetExponent); + } + + function testWithTargetExponentScaleUpNotOverflow( + int256 signedCoefficient, + int256 exponent, + int256 targetExponentDiff + ) external pure { + targetExponentDiff = bound(targetExponentDiff, int256(1), int256(76)); + exponent = bound(exponent, type(int256).min + targetExponentDiff, type(int256).max); + int256 targetExponent = exponent - targetExponentDiff; + + // Assume not overflow. + unchecked { + int256 scale = int256(10 ** uint256(exponent - targetExponent)); + int256 c = signedCoefficient * scale; + vm.assume(c / scale == signedCoefficient); + } + + int256 actualSignedCoefficient = + LibDecimalFloatImplementation.withTargetExponent(signedCoefficient, exponent, targetExponent); + int256 expectedSignedCoefficient = signedCoefficient * int256(10 ** uint256(exponent - targetExponent)); + assertEq(actualSignedCoefficient, expectedSignedCoefficient, "signedCoefficient"); + } + + function testWithTargetExponentScaleUpOverflow(int256 signedCoefficient, int256 exponent, int256 targetExponentDiff) + external + { + targetExponentDiff = bound(targetExponentDiff, int256(1), int256(76)); + exponent = bound(exponent, type(int256).min + targetExponentDiff, type(int256).max); + int256 targetExponent = exponent - targetExponentDiff; + + // Assume overflow. + unchecked { + int256 scale = int256(10 ** uint256(exponent - targetExponent)); + int256 c = signedCoefficient * scale; + vm.assume(c / scale != signedCoefficient); + } + + vm.expectRevert( + abi.encodeWithSelector(WithTargetExponentOverflow.selector, signedCoefficient, exponent, targetExponent) + ); + this.withTargetExponentExternal(signedCoefficient, exponent, targetExponent); + } } From 90fa7ab096b54f34548a1b88d452547dd8a3590c Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Sun, 21 Sep 2025 16:37:12 +0400 Subject: [PATCH 3/6] revert main changes --- .../LibDecimalFloatImplementation.sol | 282 +++++++++--------- 1 file changed, 138 insertions(+), 144 deletions(-) diff --git a/src/lib/implementation/LibDecimalFloatImplementation.sol b/src/lib/implementation/LibDecimalFloatImplementation.sol index 9e38ad83..f7ba8ede 100644 --- a/src/lib/implementation/LibDecimalFloatImplementation.sol +++ b/src/lib/implementation/LibDecimalFloatImplementation.sol @@ -547,9 +547,13 @@ library LibDecimalFloatImplementation { } // Be careful to handle overflow. if (didOverflow) { + if (type(int256).max == exponentA) { + revert ExponentOverflow(signedCoefficientA, exponentA); + } + signedCoefficientA /= 10; signedCoefficientB /= 10; - exponentA += 1; + exponentA++; signedCoefficientA += signedCoefficientB; } else { signedCoefficientA = c; @@ -619,128 +623,124 @@ library LibDecimalFloatImplementation { view returns (int256, int256) { - unchecked { - { - int256 unmaximizedCoefficient = signedCoefficient; - int256 unmaximizedExponent = exponent; - (signedCoefficient, exponent) = maximizeFull(signedCoefficient, exponent); + { + int256 unmaximizedCoefficient = signedCoefficient; + int256 unmaximizedExponent = exponent; + (signedCoefficient, exponent) = maximizeFull(signedCoefficient, exponent); - if (signedCoefficient <= 0) { - if (signedCoefficient == 0) { - revert Log10Zero(); - } else { - revert Log10Negative(unmaximizedCoefficient, unmaximizedExponent); - } + if (signedCoefficient <= 0) { + if (signedCoefficient == 0) { + revert Log10Zero(); + } else { + revert Log10Negative(unmaximizedCoefficient, unmaximizedExponent); } } + } - // all powers of 10 look like 1 with a different exponent - if (signedCoefficient == 1e76) { - return (exponent + 76, 0); - } - bool isAtLeastE76 = signedCoefficient >= 1e76; - - // This is a positive log. i.e. log(x) where x >= 1. - if (exponent >= (isAtLeastE76 ? -76 : -75)) { - int256 y1Coefficient; - int256 y2Coefficient; - int256 x1Coefficient; - int256 x2Coefficient; - // exact powers of 10 are already caught above. - // but e.g. 20 would be 2e76, -75 and true for isAtLeastE76 - // => adding exp 76 yields 1, which is the correct result. - // 200 would be 2e76, -74 and true for isAtLeastE76 - // => adding exp 76 yields 2, which is the correct result. - // however 90 would be 9e75, -74 and false for isAtLeastE76 - // => adding exp 75 yields 1, which is the correct result. - // 900 would be 9e75, -73 and false for isAtLeastE76 - // => adding exp 75 yields 2, which is the correct result. - int256 powerOfTen = exponent + int256(isAtLeastE76 ? int256(76) : int256(75)); - - // Table lookup. - { - int256 scale = 1e72; - assembly ("memory-safe") { - //slither-disable-next-line divide-before-multiply - function lookupTableVal(tables, index) -> result { - // First byte of the data contract must be skipped. - let mainOffset := add(1, mul(div(index, 10), 2)) - mstore(0, 0) - extcodecopy(tables, 30, mainOffset, 2) - let mainTableVal := mload(0) - - result := and(mainTableVal, 0x7FFF) - // Skip first byte of data contract then 1820 bytes - // of the log tables. - let smallTableOffset := 1821 - if iszero(iszero(and(mainTableVal, 0x8000))) { - // Small table is half the size of the main - // table. - smallTableOffset := add(smallTableOffset, 910) - } - - mstore(0, 0) - extcodecopy( - tables, 31, add(smallTableOffset, add(mul(div(index, 100), 10), mod(index, 10))), 1 - ) - result := add(result, mload(0)) - } + // all powers of 10 look like 1 with a different exponent + if (signedCoefficient == 1e76) { + return (exponent + 76, 0); + } + bool isAtLeastE76 = signedCoefficient >= 1e76; + + // This is a positive log. i.e. log(x) where x >= 1. + if (exponent >= (isAtLeastE76 ? -76 : -75)) { + int256 y1Coefficient; + int256 y2Coefficient; + int256 x1Coefficient; + int256 x2Coefficient; + // exact powers of 10 are already caught above. + // but e.g. 20 would be 2e76, -75 and true for isAtLeastE76 + // => adding exp 76 yields 1, which is the correct result. + // 200 would be 2e76, -74 and true for isAtLeastE76 + // => adding exp 76 yields 2, which is the correct result. + // however 90 would be 9e75, -74 and false for isAtLeastE76 + // => adding exp 75 yields 1, which is the correct result. + // 900 would be 9e75, -73 and false for isAtLeastE76 + // => adding exp 75 yields 2, which is the correct result. + int256 powerOfTen = exponent + int256(isAtLeastE76 ? int256(76) : int256(75)); - // Need to increase the scale by one OOM here so that the - // signed coefficient has 4 digits always, to make it - // easy to calculate the idx. - if isAtLeastE76 { scale := mul(scale, 10) } - - // Truncate the signed coefficient to what we can look - // up in the table. - // Slither false positive because the truncation is - // deliberate here. - //slither-disable-next-line divide-before-multiply - x1Coefficient := div(signedCoefficient, scale) - let idx := sub(x1Coefficient, 1000) - x1Coefficient := mul(x1Coefficient, scale) - // Technically we only need to do this if we need to - // interpolate but it's cheaper to just do an `add` - // unconditionally than pay for an `if` and often also - // do the `add`. - x2Coefficient := add(x1Coefficient, scale) - - // If we don't bring the scale back down here we can get - // overflows when multiplying the output of the lookups. - // We are reusing the same scale variable to avoid a - // compiler stack overflow. - // Slither false positive here, this division is simply - // the inverse of the mul above. - //slither-disable-next-line divide-before-multiply - if isAtLeastE76 { scale := div(scale, 10) } - - y1Coefficient := mul(scale, lookupTableVal(tablesDataContract, idx)) - // Only do the second lookup if we expect interpolation - // to need it. - if iszero(eq(x1Coefficient, signedCoefficient)) { - y2Coefficient := mul(scale, lookupTableVal(tablesDataContract, add(idx, 1))) + // Table lookup. + { + int256 scale = 1e72; + assembly ("memory-safe") { + //slither-disable-next-line divide-before-multiply + function lookupTableVal(tables, index) -> result { + // First byte of the data contract must be skipped. + let mainOffset := add(1, mul(div(index, 10), 2)) + mstore(0, 0) + extcodecopy(tables, 30, mainOffset, 2) + let mainTableVal := mload(0) + + result := and(mainTableVal, 0x7FFF) + // Skip first byte of data contract then 1820 bytes + // of the log tables. + let smallTableOffset := 1821 + if iszero(iszero(and(mainTableVal, 0x8000))) { + // Small table is half the size of the main + // table. + smallTableOffset := add(smallTableOffset, 910) } + + mstore(0, 0) + extcodecopy(tables, 31, add(smallTableOffset, add(mul(div(index, 100), 10), mod(index, 10))), 1) + result := add(result, mload(0)) } - } - (signedCoefficient, exponent) = unitLinearInterpolation( - x1Coefficient, - signedCoefficient, - x2Coefficient, - exponent, - y1Coefficient, - y2Coefficient, - LOG10_Y_EXPONENT - ); - return add(signedCoefficient, exponent, powerOfTen, 0); - } - // This is a negative log. i.e. log(x) where 0 < x < 1. - // log(x) = -log(1/x) - else { - (signedCoefficient, exponent) = inv(signedCoefficient, exponent); - (signedCoefficient, exponent) = log10(tablesDataContract, signedCoefficient, exponent); - return minus(signedCoefficient, exponent); + // Need to increase the scale by one OOM here so that the + // signed coefficient has 4 digits always, to make it + // easy to calculate the idx. + if isAtLeastE76 { scale := mul(scale, 10) } + + // Truncate the signed coefficient to what we can look + // up in the table. + // Slither false positive because the truncation is + // deliberate here. + //slither-disable-next-line divide-before-multiply + x1Coefficient := div(signedCoefficient, scale) + let idx := sub(x1Coefficient, 1000) + x1Coefficient := mul(x1Coefficient, scale) + // Technically we only need to do this if we need to + // interpolate but it's cheaper to just do an `add` + // unconditionally than pay for an `if` and often also + // do the `add`. + x2Coefficient := add(x1Coefficient, scale) + + // If we don't bring the scale back down here we can get + // overflows when multiplying the output of the lookups. + // We are reusing the same scale variable to avoid a + // compiler stack overflow. + // Slither false positive here, this division is simply + // the inverse of the mul above. + //slither-disable-next-line divide-before-multiply + if isAtLeastE76 { scale := div(scale, 10) } + + y1Coefficient := mul(scale, lookupTableVal(tablesDataContract, idx)) + // Only do the second lookup if we expect interpolation + // to need it. + if iszero(eq(x1Coefficient, signedCoefficient)) { + y2Coefficient := mul(scale, lookupTableVal(tablesDataContract, add(idx, 1))) + } + } } + + (signedCoefficient, exponent) = unitLinearInterpolation( + x1Coefficient, + signedCoefficient, + x2Coefficient, + exponent, + y1Coefficient, + y2Coefficient, + LOG10_Y_EXPONENT + ); + return add(signedCoefficient, exponent, powerOfTen, 0); + } + // This is a negative log. i.e. log(x) where 0 < x < 1. + // log(x) = -log(1/x) + else { + (signedCoefficient, exponent) = inv(signedCoefficient, exponent); + (signedCoefficient, exponent) = log10(tablesDataContract, signedCoefficient, exponent); + return minus(signedCoefficient, exponent); } } @@ -760,36 +760,32 @@ library LibDecimalFloatImplementation { view returns (int256, int256) { - unchecked { - if (signedCoefficient < 0) { - (signedCoefficient, exponent) = minus(signedCoefficient, exponent); - (signedCoefficient, exponent) = pow10(tablesDataContract, signedCoefficient, exponent); - return inv(signedCoefficient, exponent); - } + if (signedCoefficient < 0) { + (signedCoefficient, exponent) = minus(signedCoefficient, exponent); + (signedCoefficient, exponent) = pow10(tablesDataContract, signedCoefficient, exponent); + return inv(signedCoefficient, exponent); + } - // Table lookup. - (int256 characteristicCoefficient, int256 mantissaCoefficient) = - characteristicMantissa(signedCoefficient, exponent); - int256 characteristicExponent = exponent; - { - (int256 idx, bool interpolate, int256 scale) = mantissa4(mantissaCoefficient, exponent); - (int256 y1Coefficient, int256 y2Coefficient) = - lookupAntilogTableY1Y2(tablesDataContract, uint256(idx), interpolate); - if (interpolate) { - (signedCoefficient, exponent) = unitLinearInterpolation( - idx * scale, mantissaCoefficient, (idx + 1) * scale, exponent, y1Coefficient, y2Coefficient, -4 - ); - } else { - signedCoefficient = y1Coefficient; - exponent = -4; - } + // Table lookup. + (int256 characteristicCoefficient, int256 mantissaCoefficient) = + characteristicMantissa(signedCoefficient, exponent); + int256 characteristicExponent = exponent; + { + (int256 idx, bool interpolate, int256 scale) = mantissa4(mantissaCoefficient, exponent); + (int256 y1Coefficient, int256 y2Coefficient) = + lookupAntilogTableY1Y2(tablesDataContract, uint256(idx), interpolate); + if (interpolate) { + (signedCoefficient, exponent) = unitLinearInterpolation( + idx * scale, mantissaCoefficient, (idx + 1) * scale, exponent, y1Coefficient, y2Coefficient, -4 + ); + } else { + signedCoefficient = y1Coefficient; + exponent = -4; } - - return ( - signedCoefficient, - 1 + exponent + withTargetExponent(characteristicCoefficient, characteristicExponent, 0) - ); } + + return + (signedCoefficient, 1 + exponent + withTargetExponent(characteristicCoefficient, characteristicExponent, 0)); } /// @return signedCoefficient The maximized signed coefficient. @@ -969,9 +965,7 @@ library LibDecimalFloatImplementation { return signedCoefficient; } else if (targetExponent > exponent) { int256 exponentDiff = targetExponent - exponent; - // exponentDiff can overflow if targetExponent is sufficiently - // positive and exponent is sufficiently negative. - if (exponentDiff > 76 || exponentDiff <= 0) { + if (exponentDiff > 76 || exponentDiff < 0) { return (MAXIMIZED_ZERO_SIGNED_COEFFICIENT); } From 155eea9538ea135352959569a7eeb630a489ab0d Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Sun, 21 Sep 2025 18:59:50 +0400 Subject: [PATCH 4/6] lint --- .gas-snapshot | 403 +++++++++--------- .../LibDecimalFloatImplementation.sol | 4 +- 2 files changed, 207 insertions(+), 200 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index ec8034fe..ee479929 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,182 +1,182 @@ -DecimalFloatAbsTest:testAbsDeployed(bytes32) (runs: 5106, μ: 3264809, ~: 3264749) -DecimalFloatAddTest:testAddDeployed(bytes32,bytes32) (runs: 5106, μ: 3270277, ~: 3270334) -DecimalFloatCeilTest:testCeilDeployed(bytes32) (runs: 5106, μ: 3264787, ~: 3264412) -DecimalFloatConstantsTest:testEDeployed() (gas: 3263942) -DecimalFloatConstantsTest:testMaxNegativeValueDeployed() (gas: 3263931) -DecimalFloatConstantsTest:testMaxPositiveValueDeployed() (gas: 3263932) -DecimalFloatConstantsTest:testMinNegativeValueDeployed() (gas: 3263907) -DecimalFloatConstantsTest:testMinPositiveValueDeployed() (gas: 3263908) -DecimalFloatConstantsTest:testZeroDeployed() (gas: 3263975) -DecimalFloatDivTest:testDivDeployed(bytes32,bytes32) (runs: 5106, μ: 3271788, ~: 3271912) -DecimalFloatEqTest:testEqDeployed(bytes32,bytes32) (runs: 5106, μ: 3265142, ~: 3265067) -DecimalFloatFloorTest:testFloorDeployed(bytes32) (runs: 5106, μ: 3264590, ~: 3264410) -DecimalFloatFormatTest:testFormatDeployed(bytes32,uint256) (runs: 5106, μ: 3290309, ~: 3296672) -DecimalFloatFracTest:testFracDeployed(bytes32) (runs: 5106, μ: 3264994, ~: 3264960) -DecimalFloatFromFixedDecimalLosslessTest:testFromFixedDecimalLosslessDeployed(uint256,uint8) (runs: 5106, μ: 3265587, ~: 3265528) -DecimalFloatFromFixedDecimalLossyTest:testFromFixedDecimalLossyDeployed(uint256,uint8) (runs: 5106, μ: 3266077, ~: 3265995) -DecimalFloatGtTest:testGtDeployed(bytes32,bytes32) (runs: 5106, μ: 3265084, ~: 3265009) -DecimalFloatGteTest:testGteDeployed(bytes32,bytes32) (runs: 5106, μ: 3265070, ~: 3264995) -DecimalFloatInvTest:testInvDeployed(bytes32) (runs: 5106, μ: 3270243, ~: 3270304) -DecimalFloatIsZeroTest:testIsZeroDeployed(bytes32) (runs: 5106, μ: 3264252, ~: 3264252) -DecimalFloatLtTest:testLtDeployed(bytes32,bytes32) (runs: 5106, μ: 3265061, ~: 3264986) -DecimalFloatLteTest:testLteDeployed(bytes32,bytes32) (runs: 5106, μ: 3265114, ~: 3265039) -DecimalFloatMaxTest:testMaxDeployed(bytes32,bytes32) (runs: 5106, μ: 3265123, ~: 3265061) -DecimalFloatMinTest:testMinDeployed(bytes32,bytes32) (runs: 5106, μ: 3265121, ~: 3265059) -DecimalFloatMinusTest:testMinusDeployed(bytes32) (runs: 5106, μ: 3264917, ~: 3264918) -DecimalFloatMulTest:testMulDeployed(bytes32,bytes32) (runs: 5106, μ: 3268750, ~: 3269531) -DecimalFloatPackLosslessTest:testPackDeployed(int224,int32) (runs: 5106, μ: 170044, ~: 170045) -DecimalFloatParseTest:testParseDeployed(string) (runs: 5106, μ: 3267490, ~: 3267359) -DecimalFloatPowTest:testPowDeployed(bytes32,bytes32) (runs: 5106, μ: 3279533, ~: 3277829) -DecimalFloatSqrtTest:testSqrtDeployed(bytes32) (runs: 5106, μ: 3279509, ~: 3279047) -DecimalFloatSubTest:testSubDeployed(bytes32,bytes32) (runs: 5106, μ: 3270585, ~: 3270659) -DecimalFloatToFixedDecimalLosslessTest:testToFixedDecimalLosslessDeployed(bytes32,uint8) (runs: 5106, μ: 3266220, ~: 3266102) -DecimalFloatToFixedDecimalLossyTest:testToFixedDecimalLossyDeployed(bytes32,uint8) (runs: 5106, μ: 3266315, ~: 3266586) -LibDecimalFloatAbsTest:testAbsMinValue(int32) (runs: 5106, μ: 5162, ~: 5162) -LibDecimalFloatAbsTest:testAbsNegative(int256,int32) (runs: 5106, μ: 10527, ~: 10754) -LibDecimalFloatAbsTest:testAbsNonNegative(int256,int32) (runs: 5106, μ: 9714, ~: 9463) +DecimalFloatAbsTest:testAbsDeployed(bytes32) (runs: 5107, μ: 3265209, ~: 3265149) +DecimalFloatAddTest:testAddDeployed(bytes32,bytes32) (runs: 5107, μ: 3270677, ~: 3270734) +DecimalFloatCeilTest:testCeilDeployed(bytes32) (runs: 5107, μ: 3265188, ~: 3264812) +DecimalFloatConstantsTest:testEDeployed() (gas: 3264342) +DecimalFloatConstantsTest:testMaxNegativeValueDeployed() (gas: 3264331) +DecimalFloatConstantsTest:testMaxPositiveValueDeployed() (gas: 3264332) +DecimalFloatConstantsTest:testMinNegativeValueDeployed() (gas: 3264307) +DecimalFloatConstantsTest:testMinPositiveValueDeployed() (gas: 3264308) +DecimalFloatConstantsTest:testZeroDeployed() (gas: 3264375) +DecimalFloatDivTest:testDivDeployed(bytes32,bytes32) (runs: 5107, μ: 3272188, ~: 3272312) +DecimalFloatEqTest:testEqDeployed(bytes32,bytes32) (runs: 5107, μ: 3265542, ~: 3265467) +DecimalFloatFloorTest:testFloorDeployed(bytes32) (runs: 5107, μ: 3264990, ~: 3264810) +DecimalFloatFormatTest:testFormatDeployed(bytes32,uint256) (runs: 5107, μ: 3290710, ~: 3297072) +DecimalFloatFracTest:testFracDeployed(bytes32) (runs: 5107, μ: 3265394, ~: 3265360) +DecimalFloatFromFixedDecimalLosslessTest:testFromFixedDecimalLosslessDeployed(uint256,uint8) (runs: 5107, μ: 3265987, ~: 3265928) +DecimalFloatFromFixedDecimalLossyTest:testFromFixedDecimalLossyDeployed(uint256,uint8) (runs: 5107, μ: 3266477, ~: 3266395) +DecimalFloatGtTest:testGtDeployed(bytes32,bytes32) (runs: 5107, μ: 3265484, ~: 3265409) +DecimalFloatGteTest:testGteDeployed(bytes32,bytes32) (runs: 5107, μ: 3265470, ~: 3265395) +DecimalFloatInvTest:testInvDeployed(bytes32) (runs: 5107, μ: 3270643, ~: 3270704) +DecimalFloatIsZeroTest:testIsZeroDeployed(bytes32) (runs: 5107, μ: 3264652, ~: 3264652) +DecimalFloatLtTest:testLtDeployed(bytes32,bytes32) (runs: 5107, μ: 3265461, ~: 3265386) +DecimalFloatLteTest:testLteDeployed(bytes32,bytes32) (runs: 5107, μ: 3265514, ~: 3265439) +DecimalFloatMaxTest:testMaxDeployed(bytes32,bytes32) (runs: 5107, μ: 3265523, ~: 3265461) +DecimalFloatMinTest:testMinDeployed(bytes32,bytes32) (runs: 5107, μ: 3265521, ~: 3265459) +DecimalFloatMinusTest:testMinusDeployed(bytes32) (runs: 5107, μ: 3265317, ~: 3265318) +DecimalFloatMulTest:testMulDeployed(bytes32,bytes32) (runs: 5107, μ: 3269150, ~: 3269931) +DecimalFloatPackLosslessTest:testPackDeployed(int224,int32) (runs: 5107, μ: 170044, ~: 170045) +DecimalFloatParseTest:testParseDeployed(string) (runs: 5107, μ: 3267890, ~: 3267759) +DecimalFloatPowTest:testPowDeployed(bytes32,bytes32) (runs: 5107, μ: 3279909, ~: 3278229) +DecimalFloatSqrtTest:testSqrtDeployed(bytes32) (runs: 5107, μ: 3279961, ~: 3279453) +DecimalFloatSubTest:testSubDeployed(bytes32,bytes32) (runs: 5107, μ: 3270985, ~: 3271059) +DecimalFloatToFixedDecimalLosslessTest:testToFixedDecimalLosslessDeployed(bytes32,uint8) (runs: 5107, μ: 3266619, ~: 3266502) +DecimalFloatToFixedDecimalLossyTest:testToFixedDecimalLossyDeployed(bytes32,uint8) (runs: 5107, μ: 3266715, ~: 3266986) +LibDecimalFloatAbsTest:testAbsMinValue(int32) (runs: 5107, μ: 5162, ~: 5162) +LibDecimalFloatAbsTest:testAbsNegative(int256,int32) (runs: 5107, μ: 10527, ~: 10754) +LibDecimalFloatAbsTest:testAbsNonNegative(int256,int32) (runs: 5107, μ: 9714, ~: 9463) LibDecimalFloatCeilTest:testCeilExamples() (gas: 35053) -LibDecimalFloatCeilTest:testCeilInRange(int224,int256) (runs: 5106, μ: 11143, ~: 10763) -LibDecimalFloatCeilTest:testCeilLessThanMin(int224,int256) (runs: 5106, μ: 10079, ~: 9840) -LibDecimalFloatCeilTest:testCeilNonNegative(int224,int256) (runs: 5106, μ: 8985, ~: 9237) -LibDecimalFloatCeilTest:testCeilNotReverts(bytes32) (runs: 5106, μ: 603, ~: 411) -LibDecimalFloatCeilTest:testCeilZero(int32) (runs: 5106, μ: 5428, ~: 5428) +LibDecimalFloatCeilTest:testCeilInRange(int224,int256) (runs: 5107, μ: 11143, ~: 10763) +LibDecimalFloatCeilTest:testCeilLessThanMin(int224,int256) (runs: 5107, μ: 10079, ~: 9840) +LibDecimalFloatCeilTest:testCeilNonNegative(int224,int256) (runs: 5107, μ: 8985, ~: 9237) +LibDecimalFloatCeilTest:testCeilNotReverts(bytes32) (runs: 5107, μ: 603, ~: 411) +LibDecimalFloatCeilTest:testCeilZero(int32) (runs: 5107, μ: 5428, ~: 5428) LibDecimalFloatConstantsTest:testFloatE() (gas: 3383) LibDecimalFloatConstantsTest:testFloatHalf() (gas: 3362) LibDecimalFloatConstantsTest:testFloatMaxNegativeValue() (gas: 3405) -LibDecimalFloatConstantsTest:testFloatMaxNegativeValueIsMax(bytes32) (runs: 5106, μ: 4505, ~: 4620) +LibDecimalFloatConstantsTest:testFloatMaxNegativeValueIsMax(bytes32) (runs: 5107, μ: 4505, ~: 4620) LibDecimalFloatConstantsTest:testFloatMaxPositiveValue() (gas: 3361) -LibDecimalFloatConstantsTest:testFloatMaxPositiveValueIsMax(bytes32) (runs: 5106, μ: 3545, ~: 3586) +LibDecimalFloatConstantsTest:testFloatMaxPositiveValueIsMax(bytes32) (runs: 5107, μ: 3545, ~: 3586) LibDecimalFloatConstantsTest:testFloatMinNegativeValue() (gas: 3361) -LibDecimalFloatConstantsTest:testFloatMinNegativeValueIsMin(bytes32) (runs: 5106, μ: 3496, ~: 3457) +LibDecimalFloatConstantsTest:testFloatMinNegativeValueIsMin(bytes32) (runs: 5107, μ: 3496, ~: 3457) LibDecimalFloatConstantsTest:testFloatMinPositiveValue() (gas: 3383) -LibDecimalFloatConstantsTest:testFloatMinPositiveValueIsMin(bytes32) (runs: 5106, μ: 4965, ~: 4896) +LibDecimalFloatConstantsTest:testFloatMinPositiveValueIsMin(bytes32) (runs: 5107, μ: 4965, ~: 4896) LibDecimalFloatConstantsTest:testFloatOne() (gas: 3384) LibDecimalFloatConstantsTest:testFloatTwo() (gas: 3406) LibDecimalFloatConstantsTest:testFloatZero() (gas: 3332) -LibDecimalFloatDecimalAddTest:testAddPacked(bytes32,bytes32) (runs: 5106, μ: 11217, ~: 11316) -LibDecimalFloatDecimalLosslessTest:testFromFixedDecimalLosslessFail(uint256,uint8) (runs: 5106, μ: 9616, ~: 9663) -LibDecimalFloatDecimalLosslessTest:testFromFixedDecimalLosslessMem(uint256,uint8) (runs: 5106, μ: 8187, ~: 8104) -LibDecimalFloatDecimalLosslessTest:testFromFixedDecimalLosslessPass(uint256,uint8) (runs: 5106, μ: 7452, ~: 7424) +LibDecimalFloatDecimalAddTest:testAddPacked(bytes32,bytes32) (runs: 5107, μ: 11217, ~: 11314) +LibDecimalFloatDecimalLosslessTest:testFromFixedDecimalLosslessFail(uint256,uint8) (runs: 5107, μ: 9616, ~: 9663) +LibDecimalFloatDecimalLosslessTest:testFromFixedDecimalLosslessMem(uint256,uint8) (runs: 5107, μ: 8187, ~: 8104) +LibDecimalFloatDecimalLosslessTest:testFromFixedDecimalLosslessPass(uint256,uint8) (runs: 5107, μ: 7452, ~: 7424) LibDecimalFloatDecimalLosslessTest:testToFixedDecimalLosslessFail() (gas: 4894) -LibDecimalFloatDecimalLosslessTest:testToFixedDecimalLosslessPacked(bytes32,uint8) (runs: 5106, μ: 6729, ~: 6161) -LibDecimalFloatDecimalLosslessTest:testToFixedDecimalLosslessPass(int256,int256,uint8) (runs: 5106, μ: 15813, ~: 15768) -LibDecimalFloatDecimalTest:testFixedDecimalRoundTripLossless(uint256,uint8) (runs: 5106, μ: 9111, ~: 9031) +LibDecimalFloatDecimalLosslessTest:testToFixedDecimalLosslessPacked(bytes32,uint8) (runs: 5107, μ: 6729, ~: 6161) +LibDecimalFloatDecimalLosslessTest:testToFixedDecimalLosslessPass(int256,int256,uint8) (runs: 5107, μ: 15813, ~: 15768) +LibDecimalFloatDecimalTest:testFixedDecimalRoundTripLossless(uint256,uint8) (runs: 5107, μ: 9111, ~: 9031) LibDecimalFloatDecimalTest:testFromFixedDecimalLossyComplicated() (gas: 685958) LibDecimalFloatDecimalTest:testFromFixedDecimalLossyMax() (gas: 673463) LibDecimalFloatDecimalTest:testFromFixedDecimalLossyOne() (gas: 686002) LibDecimalFloatDecimalTest:testFromFixedDecimalLossyOneMillion() (gas: 685937) LibDecimalFloatDecimalTest:testFromFixedDecimalLossyOverflow() (gas: 715261) -LibDecimalFloatDecimalTest:testFromFixedDecimalLossyPacked(uint256,uint8) (runs: 5106, μ: 9537, ~: 9452) -LibDecimalFloatDecimalTest:testFromFixedDecimalLossyTruncateOne(uint256,uint8) (runs: 5106, μ: 5978, ~: 5937) -LibDecimalFloatDecimalTest:testFromFixedDecimalLossyTruncateZero(uint256,uint8) (runs: 5106, μ: 6067, ~: 5860) +LibDecimalFloatDecimalTest:testFromFixedDecimalLossyPacked(uint256,uint8) (runs: 5107, μ: 9537, ~: 9452) +LibDecimalFloatDecimalTest:testFromFixedDecimalLossyTruncateOne(uint256,uint8) (runs: 5107, μ: 5978, ~: 5937) +LibDecimalFloatDecimalTest:testFromFixedDecimalLossyTruncateZero(uint256,uint8) (runs: 5107, μ: 6067, ~: 5860) LibDecimalFloatDecimalTest:testToFixedDecimalLosslessScaleUp(int256,int256,uint8) (runs: 5103, μ: 15997, ~: 15929) -LibDecimalFloatDecimalTest:testToFixedDecimalLossyExponentOverflow(int256,int256,uint8) (runs: 5106, μ: 14963, ~: 14729) -LibDecimalFloatDecimalTest:testToFixedDecimalLossyIdentity(int256,uint8) (runs: 5106, μ: 10155, ~: 9957) -LibDecimalFloatDecimalTest:testToFixedDecimalLossyNegative(int256,int256,uint8) (runs: 5106, μ: 10825, ~: 11076) -LibDecimalFloatDecimalTest:testToFixedDecimalLossyPacked(bytes32,uint8) (runs: 5106, μ: 6813, ~: 6905) -LibDecimalFloatDecimalTest:testToFixedDecimalLossyScaleUpOverflow(int256,int256,uint8) (runs: 5099, μ: 15351, ~: 15612) -LibDecimalFloatDecimalTest:testToFixedDecimalLossyTruncate(int256,int256,uint8) (runs: 5106, μ: 14493, ~: 14212) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyExponentOverflow(int256,int256,uint8) (runs: 5107, μ: 14963, ~: 14729) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyIdentity(int256,uint8) (runs: 5107, μ: 10155, ~: 9957) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyNegative(int256,int256,uint8) (runs: 5107, μ: 10825, ~: 11076) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyPacked(bytes32,uint8) (runs: 5107, μ: 6813, ~: 6905) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyScaleUpOverflow(int256,int256,uint8) (runs: 5100, μ: 15351, ~: 15612) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyTruncate(int256,int256,uint8) (runs: 5107, μ: 14493, ~: 14212) LibDecimalFloatDecimalTest:testToFixedDecimalLossyTruncateLossless() (gas: 14500) -LibDecimalFloatDecimalTest:testToFixedDecimalLossyUnderflow(int256,int256,uint8) (runs: 5106, μ: 13738, ~: 13602) -LibDecimalFloatDecimalTest:testToFixedDecimalLossyZero(int256,uint8) (runs: 5106, μ: 4575, ~: 4575) -LibDecimalFloatDivTest:testDivByNegativeOneFloat(int224,int32) (runs: 5106, μ: 361808, ~: 358393) -LibDecimalFloatDivTest:testDivByOneFloat(int224,int32) (runs: 5106, μ: 336378, ~: 333291) -LibDecimalFloatDivTest:testDivPacked(bytes32,bytes32) (runs: 5106, μ: 12706, ~: 12844) -LibDecimalFloatEqTest:testEqPacked(bytes32,bytes32) (runs: 5106, μ: 5524, ~: 5450) -LibDecimalFloatEqTest:testEqXNotYExponents(bytes32,bytes32) (runs: 5106, μ: 4341, ~: 4234) -LibDecimalFloatEqTest:testEqZero(int32) (runs: 5106, μ: 5123, ~: 5123) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyUnderflow(int256,int256,uint8) (runs: 5107, μ: 13738, ~: 13602) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyZero(int256,uint8) (runs: 5107, μ: 4575, ~: 4575) +LibDecimalFloatDivTest:testDivByNegativeOneFloat(int224,int32) (runs: 5107, μ: 361764, ~: 358393) +LibDecimalFloatDivTest:testDivByOneFloat(int224,int32) (runs: 5107, μ: 336335, ~: 333291) +LibDecimalFloatDivTest:testDivPacked(bytes32,bytes32) (runs: 5107, μ: 12706, ~: 12844) +LibDecimalFloatEqTest:testEqPacked(bytes32,bytes32) (runs: 5107, μ: 5524, ~: 5450) +LibDecimalFloatEqTest:testEqXNotYExponents(bytes32,bytes32) (runs: 5107, μ: 4341, ~: 4234) +LibDecimalFloatEqTest:testEqZero(int32) (runs: 5107, μ: 5123, ~: 5123) LibDecimalFloatFloorTest:testFloorExamples() (gas: 39140) LibDecimalFloatFloorTest:testFloorGas0() (gas: 1003) LibDecimalFloatFloorTest:testFloorGasTiny() (gas: 902) LibDecimalFloatFloorTest:testFloorGasZero() (gas: 548) -LibDecimalFloatFloorTest:testFloorInRange(int224,int256) (runs: 5106, μ: 11101, ~: 11130) -LibDecimalFloatFloorTest:testFloorLessThanMin(int224,int256) (runs: 5106, μ: 10302, ~: 10314) -LibDecimalFloatFloorTest:testFloorNonNegative(int224,int256) (runs: 5106, μ: 9591, ~: 9851) -LibDecimalFloatFloorTest:testFloorNotReverts(bytes32) (runs: 5106, μ: 459, ~: 365) +LibDecimalFloatFloorTest:testFloorInRange(int224,int256) (runs: 5107, μ: 11101, ~: 11130) +LibDecimalFloatFloorTest:testFloorLessThanMin(int224,int256) (runs: 5107, μ: 10302, ~: 10314) +LibDecimalFloatFloorTest:testFloorNonNegative(int224,int256) (runs: 5107, μ: 9591, ~: 9851) +LibDecimalFloatFloorTest:testFloorNotReverts(bytes32) (runs: 5107, μ: 459, ~: 365) LibDecimalFloatFracTest:testFracExamples() (gas: 40054) LibDecimalFloatFracTest:testFracGas0() (gas: 1003) LibDecimalFloatFracTest:testFracGasTiny() (gas: 888) LibDecimalFloatFracTest:testFracGasZero() (gas: 810) -LibDecimalFloatFracTest:testFracInRange(int224,int256) (runs: 5106, μ: 10917, ~: 10934) -LibDecimalFloatFracTest:testFracLessThanMin(int224,int256) (runs: 5106, μ: 10343, ~: 10351) -LibDecimalFloatFracTest:testFracNonNegative(int224,int256) (runs: 5106, μ: 9825, ~: 10087) -LibDecimalFloatFracTest:testFracNotReverts(bytes32) (runs: 5106, μ: 634, ~: 616) +LibDecimalFloatFracTest:testFracInRange(int224,int256) (runs: 5107, μ: 10917, ~: 10934) +LibDecimalFloatFracTest:testFracLessThanMin(int224,int256) (runs: 5107, μ: 10343, ~: 10351) +LibDecimalFloatFracTest:testFracNonNegative(int224,int256) (runs: 5107, μ: 9826, ~: 10087) +LibDecimalFloatFracTest:testFracNotReverts(bytes32) (runs: 5107, μ: 634, ~: 616) LibDecimalFloatGtTest:testGtGasAZero() (gas: 994) LibDecimalFloatGtTest:testGtGasBZero() (gas: 994) LibDecimalFloatGtTest:testGtGasBothZero() (gas: 746) LibDecimalFloatGtTest:testGtGasDifferentSigns() (gas: 1026) LibDecimalFloatGtTest:testGtGasExponentDiffOverflow() (gas: 1195) -LibDecimalFloatGtTest:testGtOneEAny(bytes32) (runs: 5106, μ: 3494, ~: 3494) -LibDecimalFloatGtTest:testGtReference(int224,int32,int224,int32) (runs: 5106, μ: 8121, ~: 6350) -LibDecimalFloatGtTest:testGtX(int224,int32) (runs: 5106, μ: 3907, ~: 3908) -LibDecimalFloatGtTest:testGtXEAnyVsXEAny(int256,int32,int32) (runs: 5106, μ: 10644, ~: 10384) -LibDecimalFloatGtTest:testGtXEAnyVsXEAnyNegative(int256,int32,int32) (runs: 5106, μ: 11196, ~: 11401) -LibDecimalFloatGtTest:testGtXNotY(bytes32,bytes32) (runs: 5106, μ: 4341, ~: 4232) -LibDecimalFloatGtTest:testGtXPositiveYNegative(int256,int32,int256,int32) (runs: 5106, μ: 13816, ~: 13647) -LibDecimalFloatGtTest:testGtXPositiveYZero(int256,int32,int32) (runs: 5106, μ: 10294, ~: 10047) -LibDecimalFloatGtTest:testGtZero(int32,int32) (runs: 5106, μ: 4783, ~: 4783) +LibDecimalFloatGtTest:testGtOneEAny(bytes32) (runs: 5107, μ: 3494, ~: 3494) +LibDecimalFloatGtTest:testGtReference(int224,int32,int224,int32) (runs: 5107, μ: 8120, ~: 6350) +LibDecimalFloatGtTest:testGtX(int224,int32) (runs: 5107, μ: 3907, ~: 3908) +LibDecimalFloatGtTest:testGtXEAnyVsXEAny(int256,int32,int32) (runs: 5107, μ: 10644, ~: 10384) +LibDecimalFloatGtTest:testGtXEAnyVsXEAnyNegative(int256,int32,int32) (runs: 5107, μ: 11196, ~: 11401) +LibDecimalFloatGtTest:testGtXNotY(bytes32,bytes32) (runs: 5107, μ: 4341, ~: 4232) +LibDecimalFloatGtTest:testGtXPositiveYNegative(int256,int32,int256,int32) (runs: 5107, μ: 13816, ~: 13647) +LibDecimalFloatGtTest:testGtXPositiveYZero(int256,int32,int32) (runs: 5107, μ: 10295, ~: 10047) +LibDecimalFloatGtTest:testGtZero(int32,int32) (runs: 5107, μ: 4783, ~: 4783) LibDecimalFloatGteTest:testGteGasAZero() (gas: 997) LibDecimalFloatGteTest:testGteGasBZero() (gas: 1041) LibDecimalFloatGteTest:testGteGasBothZero() (gas: 748) LibDecimalFloatGteTest:testGteGasDifferentSigns() (gas: 1048) LibDecimalFloatGteTest:testGteGasExponentDiffOverflow() (gas: 1154) -LibDecimalFloatGteTest:testGteOneEAny(bytes32) (runs: 5106, μ: 3494, ~: 3494) -LibDecimalFloatGteTest:testGteReference(int224,int32,int224,int32) (runs: 5106, μ: 8170, ~: 6396) -LibDecimalFloatGteTest:testGteX(int224,int32) (runs: 5106, μ: 3950, ~: 3951) -LibDecimalFloatGteTest:testGteXEAnyVsXEAny(int256,int32,int32) (runs: 5106, μ: 10675, ~: 10416) -LibDecimalFloatGteTest:testGteXEAnyVsXEAnyNegative(int256,int32,int32) (runs: 5106, μ: 11207, ~: 11413) -LibDecimalFloatGteTest:testGteXNotLtY(bytes32,bytes32) (runs: 5106, μ: 3948, ~: 3873) -LibDecimalFloatGteTest:testGteXPositiveYNegative(int256,int32,int256,int32) (runs: 5106, μ: 13844, ~: 13675) -LibDecimalFloatGteTest:testGteXPositiveYZero(int256,int32,int32) (runs: 5106, μ: 9572, ~: 9191) -LibDecimalFloatGteTest:testGteZero(int32,int32) (runs: 5106, μ: 4828, ~: 4828) +LibDecimalFloatGteTest:testGteOneEAny(bytes32) (runs: 5107, μ: 3494, ~: 3494) +LibDecimalFloatGteTest:testGteReference(int224,int32,int224,int32) (runs: 5107, μ: 8169, ~: 6396) +LibDecimalFloatGteTest:testGteX(int224,int32) (runs: 5107, μ: 3950, ~: 3951) +LibDecimalFloatGteTest:testGteXEAnyVsXEAny(int256,int32,int32) (runs: 5107, μ: 10675, ~: 10416) +LibDecimalFloatGteTest:testGteXEAnyVsXEAnyNegative(int256,int32,int32) (runs: 5107, μ: 11207, ~: 11413) +LibDecimalFloatGteTest:testGteXNotLtY(bytes32,bytes32) (runs: 5107, μ: 3948, ~: 3873) +LibDecimalFloatGteTest:testGteXPositiveYNegative(int256,int32,int256,int32) (runs: 5107, μ: 13844, ~: 13675) +LibDecimalFloatGteTest:testGteXPositiveYZero(int256,int32,int32) (runs: 5107, μ: 9572, ~: 9191) +LibDecimalFloatGteTest:testGteZero(int32,int32) (runs: 5107, μ: 4828, ~: 4828) LibDecimalFloatImplementationAddTest:testAdd123456789987654321() (gas: 5327) LibDecimalFloatImplementationAddTest:testAdd123456789e9987654321() (gas: 5377) -LibDecimalFloatImplementationAddTest:testAddNeverRevert(int256,int256,int256,int256) (runs: 5106, μ: 13733, ~: 13711) +LibDecimalFloatImplementationAddTest:testAddNeverRevert(int256,int256,int256,int256) (runs: 5107, μ: 13733, ~: 13711) LibDecimalFloatImplementationAddTest:testAddOneOneNotMaximized() (gas: 6950) LibDecimalFloatImplementationAddTest:testAddOneOnePreMaximized() (gas: 4496) LibDecimalFloatImplementationAddTest:testAddOneZero() (gas: 3644) LibDecimalFloatImplementationAddTest:testAddRevertMaxA() (gas: 6316) -LibDecimalFloatImplementationAddTest:testAddSameExponent(int256,int256) (runs: 5105, μ: 7693, ~: 7811) +LibDecimalFloatImplementationAddTest:testAddSameExponent(int256,int256) (runs: 5106, μ: 7692, ~: 7811) LibDecimalFloatImplementationAddTest:testAddZero() (gas: 3665) -LibDecimalFloatImplementationAddTest:testAddZeroAnyExponent(int128) (runs: 5106, μ: 9293, ~: 9271) +LibDecimalFloatImplementationAddTest:testAddZeroAnyExponent(int128) (runs: 5107, μ: 9293, ~: 9271) LibDecimalFloatImplementationAddTest:testAddZeroOne() (gas: 3664) -LibDecimalFloatImplementationAddTest:testAddZeroToAnyNonZero(int256,int256,int256) (runs: 5106, μ: 14046, ~: 14015) +LibDecimalFloatImplementationAddTest:testAddZeroToAnyNonZero(int256,int256,int256) (runs: 5107, μ: 14047, ~: 14015) LibDecimalFloatImplementationAddTest:testAddingSmallToLargeReturnsLargeExamples() (gas: 107395) LibDecimalFloatImplementationAddTest:testAddingSmallToLargeReturnsLargeFuzz(int256,int256,int256,int256) (runs: 5099, μ: 18265, ~: 18316) LibDecimalFloatImplementationAddTest:testGasAddOne() (gas: 1861) LibDecimalFloatImplementationAddTest:testGasAddZero() (gas: 382) -LibDecimalFloatImplementationAddTest:testOverflowChecks(int256,int256) (runs: 5106, μ: 3879, ~: 3865) +LibDecimalFloatImplementationAddTest:testOverflowChecks(int256,int256) (runs: 5107, μ: 3879, ~: 3865) LibDecimalFloatImplementationCharacteristicMantissaTest:testCharacteristicMantissaExamples() (gas: 31315) -LibDecimalFloatImplementationCharacteristicMantissaTest:testCharacteristicMantissaNegExponentLarge(int256,int256) (runs: 5106, μ: 10532, ~: 10762) -LibDecimalFloatImplementationCharacteristicMantissaTest:testCharacteristicMantissaNegExponentSmall(int256) (runs: 5106, μ: 203163, ~: 203163) -LibDecimalFloatImplementationCharacteristicMantissaTest:testCharacteristicMantissaNonNegExponent(int256,int256) (runs: 5106, μ: 9905, ~: 9695) +LibDecimalFloatImplementationCharacteristicMantissaTest:testCharacteristicMantissaNegExponentLarge(int256,int256) (runs: 5107, μ: 10532, ~: 10762) +LibDecimalFloatImplementationCharacteristicMantissaTest:testCharacteristicMantissaNegExponentSmall(int256) (runs: 5107, μ: 203163, ~: 203163) +LibDecimalFloatImplementationCharacteristicMantissaTest:testCharacteristicMantissaNonNegExponent(int256,int256) (runs: 5107, μ: 9905, ~: 9695) LibDecimalFloatImplementationDivTest:testDiv1Over3() (gas: 7679) LibDecimalFloatImplementationDivTest:testDiv1Over3Gas0() (gas: 2566) LibDecimalFloatImplementationDivTest:testDiv1Over3Gas10() (gas: 21216) LibDecimalFloatImplementationDivTest:testDiv1Over9Over1Over3() (gas: 16036) LibDecimalFloatImplementationDivTest:testDiv1e18Over3() (gas: 7233) -LibDecimalFloatImplementationDivTest:testDivBy1(int256,int256) (runs: 5106, μ: 366448, ~: 371759) -LibDecimalFloatImplementationDivTest:testDivByNegativeOneFloat(int256,int256) (runs: 5106, μ: 368952, ~: 374524) -LibDecimalFloatImplementationDivTest:testDivMaxPositiveValueDenominatorNotRevert(int256,int256) (runs: 5106, μ: 2596, ~: 2645) +LibDecimalFloatImplementationDivTest:testDivBy1(int256,int256) (runs: 5107, μ: 366408, ~: 371759) +LibDecimalFloatImplementationDivTest:testDivByNegativeOneFloat(int256,int256) (runs: 5107, μ: 368911, ~: 374524) +LibDecimalFloatImplementationDivTest:testDivMaxPositiveValueDenominatorNotRevert(int256,int256) (runs: 5107, μ: 2595, ~: 2645) LibDecimalFloatImplementationDivTest:testDivNegative1Over3() (gas: 7774) LibDecimalFloatImplementationDivTest:testDivOOMs5and2() (gas: 6676) LibDecimalFloatImplementationDivTest:testDivOOMsOverTen() (gas: 7614) LibDecimalFloatImplementationDivTest:testDivTenOverOOMs() (gas: 7573) -LibDecimalFloatImplementationDivTest:testDivZero(int256,int256) (runs: 5106, μ: 9942, ~: 9948) -LibDecimalFloatImplementationDivTest:testUnnormalizedThreesDiv0(int256,int256) (runs: 110, μ: 29910035, ~: 29825011) +LibDecimalFloatImplementationDivTest:testDivZero(int256,int256) (runs: 5107, μ: 9942, ~: 9948) +LibDecimalFloatImplementationDivTest:testUnnormalizedThreesDiv0(int256,int256) (runs: 111, μ: 29912681, ~: 29825155) LibDecimalFloatImplementationEqTest:testEqGasAZero() (gas: 430) LibDecimalFloatImplementationEqTest:testEqGasBZero() (gas: 473) LibDecimalFloatImplementationEqTest:testEqGasBothZero() (gas: 450) LibDecimalFloatImplementationEqTest:testEqGasDifferentSigns() (gas: 482) LibDecimalFloatImplementationEqTest:testEqGasExponentDiffOverflow() (gas: 533) -LibDecimalFloatImplementationEqTest:testEqNotReverts(int256,int256,int256,int256) (runs: 5106, μ: 654, ~: 679) -LibDecimalFloatImplementationEqTest:testEqOneEAny(int256,int256) (runs: 5106, μ: 3416, ~: 3416) -LibDecimalFloatImplementationEqTest:testEqReference(int256,int256,int256,int256) (runs: 5106, μ: 9903, ~: 11446) -LibDecimalFloatImplementationEqTest:testEqX(int256) (runs: 5106, μ: 3392, ~: 3392) +LibDecimalFloatImplementationEqTest:testEqNotReverts(int256,int256,int256,int256) (runs: 5107, μ: 654, ~: 679) +LibDecimalFloatImplementationEqTest:testEqOneEAny(int256,int256) (runs: 5107, μ: 3416, ~: 3416) +LibDecimalFloatImplementationEqTest:testEqReference(int256,int256,int256,int256) (runs: 5107, μ: 9902, ~: 11437) +LibDecimalFloatImplementationEqTest:testEqX(int256) (runs: 5107, μ: 3392, ~: 3392) LibDecimalFloatImplementationEqTest:testEqXEAnyVsXEAny(int256,int256,int256) (runs: 5105, μ: 4718, ~: 4714) -LibDecimalFloatImplementationEqTest:testEqXEqY(int256,int256,int256,int256) (runs: 5106, μ: 732, ~: 753) -LibDecimalFloatImplementationEqTest:testEqXNotY(int256,int256,int256,int256) (runs: 5106, μ: 3928, ~: 3953) -LibDecimalFloatImplementationEqTest:testEqZero(int256,int256) (runs: 5106, μ: 3440, ~: 3440) +LibDecimalFloatImplementationEqTest:testEqXEqY(int256,int256,int256,int256) (runs: 5107, μ: 732, ~: 753) +LibDecimalFloatImplementationEqTest:testEqXNotY(int256,int256,int256,int256) (runs: 5107, μ: 3928, ~: 3953) +LibDecimalFloatImplementationEqTest:testEqZero(int256,int256) (runs: 5107, μ: 3440, ~: 3440) LibDecimalFloatImplementationInvTest:testInv0() (gas: 4452) LibDecimalFloatImplementationInvTest:testInvGas0() (gas: 2248) LibDecimalFloatImplementationInvTest:testInvReference(int256,int256) (runs: 5105, μ: 15281, ~: 15362) @@ -186,13 +186,13 @@ LibDecimalFloatImplementationLog10Test:testExactLookupsLog10() (gas: 1312843) LibDecimalFloatImplementationLog10Test:testInterpolatedLookups() (gas: 1262722) LibDecimalFloatImplementationLog10Test:testLog10One() (gas: 1496827) LibDecimalFloatImplementationLog10Test:testSub1() (gas: 1264080) -LibDecimalFloatImplementationMaximizeTest:testMaximizedEverything(int256,int256) (runs: 5106, μ: 9803, ~: 9799) +LibDecimalFloatImplementationMaximizeTest:testMaximizedEverything(int256,int256) (runs: 5107, μ: 9803, ~: 9799) LibDecimalFloatImplementationMaximizeTest:testMaximizedExamples() (gas: 192873) -LibDecimalFloatImplementationMaximizeTest:testMaximizedIdempotent(int256,int256) (runs: 5106, μ: 10348, ~: 10319) -LibDecimalFloatImplementationMaximizeTest:testMaximizedReference(int256,int256) (runs: 5106, μ: 13691, ~: 14630) -LibDecimalFloatImplementationMinusTest:testMinusIsSubZero(int256,int256,int256) (runs: 5106, μ: 12935, ~: 12916) +LibDecimalFloatImplementationMaximizeTest:testMaximizedIdempotent(int256,int256) (runs: 5107, μ: 10347, ~: 10319) +LibDecimalFloatImplementationMaximizeTest:testMaximizedReference(int256,int256) (runs: 5107, μ: 13690, ~: 14630) +LibDecimalFloatImplementationMinusTest:testMinusIsSubZero(int256,int256,int256) (runs: 5107, μ: 12935, ~: 12916) LibDecimalFloatImplementationMulTest:testMul123456789987654321() (gas: 5559) -LibDecimalFloatImplementationMulTest:testMul123456789987654321WithExponents(int128,int128) (runs: 5106, μ: 15078, ~: 15160) +LibDecimalFloatImplementationMulTest:testMul123456789987654321WithExponents(int128,int128) (runs: 5107, μ: 15078, ~: 15160) LibDecimalFloatImplementationMulTest:testMul1_3979_0_5() (gas: 6193) LibDecimalFloatImplementationMulTest:testMul1e181e19() (gas: 5603) LibDecimalFloatImplementationMulTest:testMulGasOne() (gas: 1470) @@ -200,110 +200,117 @@ LibDecimalFloatImplementationMulTest:testMulGasZero() (gas: 325) LibDecimalFloatImplementationMulTest:testMulMaxSignedCoefficient() (gas: 6674) LibDecimalFloatImplementationMulTest:testMulNegativeOne() (gas: 5660) LibDecimalFloatImplementationMulTest:testMulNegativeOneOne() (gas: 5659) -LibDecimalFloatImplementationMulTest:testMulNotRevertAnyExpectation(int256,int256,int256,int256) (runs: 5106, μ: 15243, ~: 14593) +LibDecimalFloatImplementationMulTest:testMulNotRevertAnyExpectation(int256,int256,int256,int256) (runs: 5107, μ: 15243, ~: 14593) LibDecimalFloatImplementationMulTest:testMulOneNegativeOne() (gas: 5635) LibDecimalFloatImplementationMulTest:testMulOneOne() (gas: 5582) LibDecimalFloatImplementationMulTest:testMulOneZero() (gas: 4481) LibDecimalFloatImplementationMulTest:testMulZero0Exponent() (gas: 4503) -LibDecimalFloatImplementationMulTest:testMulZeroAnyExponent(int64,int64) (runs: 5106, μ: 4704, ~: 4704) +LibDecimalFloatImplementationMulTest:testMulZeroAnyExponent(int64,int64) (runs: 5107, μ: 4704, ~: 4704) LibDecimalFloatImplementationMulTest:testMulZeroOne() (gas: 4438) -LibDecimalFloatImplementationPow10Test:testExactLookupsPow10() (gas: 1286039) -LibDecimalFloatImplementationPow10Test:testExactPows() (gas: 1261197) -LibDecimalFloatImplementationPow10Test:testInterpolatedLookupsPower() (gas: 1295108) -LibDecimalFloatImplementationPow10Test:testNoRevert(int224,int32) (runs: 5103, μ: 1261063, ~: 1258877) -LibDecimalFloatImplementationPow10Test:testPow10One() (gas: 1524230) +LibDecimalFloatImplementationPow10Test:testExactLookupsPow10() (gas: 1286051) +LibDecimalFloatImplementationPow10Test:testExactPows() (gas: 1261212) +LibDecimalFloatImplementationPow10Test:testInterpolatedLookupsPower() (gas: 1295117) +LibDecimalFloatImplementationPow10Test:testNoRevert(int224,int32) (runs: 5105, μ: 1261037, ~: 1258880) +LibDecimalFloatImplementationPow10Test:testPow10One() (gas: 1524458) LibDecimalFloatImplementationSubTest:testSubIsAdd(int256,int256,int256,int256) (runs: 5106, μ: 17105, ~: 17227) -LibDecimalFloatImplementationSubTest:testSubMinSignedValue(int256,int256,int256) (runs: 5106, μ: 15928, ~: 15913) +LibDecimalFloatImplementationSubTest:testSubMinSignedValue(int256,int256,int256) (runs: 5107, μ: 15928, ~: 15913) LibDecimalFloatImplementationSubTest:testSubOneFromMax() (gas: 7308) -LibDecimalFloatImplementationSubTest:testSubSelf(int224,int32) (runs: 5106, μ: 6203, ~: 6369) -LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyMixedAB(uint256,uint256,uint256,int256) (runs: 5106, μ: 9961, ~: 9888) -LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyMixedABOverflow(uint256,uint256,uint256,int256) (runs: 5106, μ: 11207, ~: 11200) -LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyMixedBA(uint256,uint256,uint256,int256) (runs: 5106, μ: 11205, ~: 11198) -LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyMixedBAOverflow(uint256,uint256,int256) (runs: 5106, μ: 9071, ~: 9018) -LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyNegative(uint256,uint256,uint256,int256) (runs: 5106, μ: 9969, ~: 9892) -LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyNegativeOverflow(uint256,uint256,uint256,int256) (runs: 5106, μ: 11201, ~: 11190) -LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyPositive(uint256,uint256,uint256,int256) (runs: 5106, μ: 9103, ~: 9033) -LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyPositiveOverflow(uint256,uint256,uint256,int256) (runs: 5106, μ: 11090, ~: 11086) -LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentExamples() (gas: 13429) -LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentLargerExponentOverflowRescaleRevert(int256,int256,int256) (runs: 5100, μ: 14426, ~: 14395) -LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentLargerExponentVeryLargeDiffRevert(int256,int256,int256) (runs: 5106, μ: 13307, ~: 13527) -LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentLargerTargetExponentNoRevert(int256,int256,int256) (runs: 5106, μ: 11669, ~: 11718) -LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentSameExponentNoop(int256,int256) (runs: 5106, μ: 3676, ~: 3676) -LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentSmallerExponentNoRevert(int256,int256,int256) (runs: 5102, μ: 13874, ~: 13665) -LibDecimalFloatInvTest:testInvMem(bytes32) (runs: 5106, μ: 11243, ~: 11322) -LibDecimalFloatIsZeroTest:testIsZeroDeployed(bytes32) (runs: 5106, μ: 3899, ~: 3899) -LibDecimalFloatIsZeroTest:testIsZeroEqZero(bytes32) (runs: 5106, μ: 3527, ~: 3527) -LibDecimalFloatIsZeroTest:testIsZeroExamples(int32) (runs: 5106, μ: 4467, ~: 4467) +LibDecimalFloatImplementationSubTest:testSubSelf(int224,int32) (runs: 5107, μ: 6203, ~: 6369) +LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyMixedAB(uint256,uint256,uint256,int256) (runs: 5107, μ: 9961, ~: 9888) +LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyMixedABOverflow(uint256,uint256,uint256,int256) (runs: 5107, μ: 11207, ~: 11200) +LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyMixedBA(uint256,uint256,uint256,int256) (runs: 5107, μ: 11205, ~: 11198) +LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyMixedBAOverflow(uint256,uint256,int256) (runs: 5107, μ: 9071, ~: 9018) +LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyNegative(uint256,uint256,uint256,int256) (runs: 5107, μ: 9969, ~: 9892) +LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyNegativeOverflow(uint256,uint256,uint256,int256) (runs: 5107, μ: 11201, ~: 11190) +LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyPositive(uint256,uint256,uint256,int256) (runs: 5107, μ: 9103, ~: 9033) +LibDecimalFloatImplementationUnabsUnsignedMulOrDivLossyTest:testUnabsUnsignedMulOrDivLossyPositiveOverflow(uint256,uint256,uint256,int256) (runs: 5107, μ: 11090, ~: 11086) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentExamples() (gas: 13427) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentExponentEqual(int256,int256) (runs: 5107, μ: 3721, ~: 3721) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentLargerExponentOverflowRescaleRevert(int256,int256,int256) (runs: 5099, μ: 14476, ~: 14443) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentLargerExponentVeryLargeDiffRevert(int256,int256,int256) (runs: 5107, μ: 13324, ~: 13425) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentLargerTargetExponentNoRevert(int256,int256,int256) (runs: 5107, μ: 11694, ~: 11897) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentMaxOverflow(int256) (runs: 5107, μ: 3769, ~: 3769) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentSameExponentNoop(int256,int256) (runs: 5107, μ: 3676, ~: 3676) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentScaleDown(int256,int256,int256) (runs: 5107, μ: 12986, ~: 12947) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentScaleUpLargeDiffRevert(int256,int256,int256) (runs: 5107, μ: 13493, ~: 13593) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentScaleUpNotOverflow(int256,int256,int256) (runs: 5105, μ: 13617, ~: 13547) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentScaleUpOverflow(int256,int256,int256) (runs: 5098, μ: 14151, ~: 14132) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentSmallerExponentNoRevert(int256,int256,int256) (runs: 5104, μ: 13873, ~: 13668) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentTargetMoreThan76Larger(int256,int256,int256) (runs: 5107, μ: 12482, ~: 12667) +LibDecimalFloatInvTest:testInvMem(bytes32) (runs: 5107, μ: 11243, ~: 11322) +LibDecimalFloatIsZeroTest:testIsZeroDeployed(bytes32) (runs: 5107, μ: 3899, ~: 3899) +LibDecimalFloatIsZeroTest:testIsZeroEqZero(bytes32) (runs: 5107, μ: 3527, ~: 3527) +LibDecimalFloatIsZeroTest:testIsZeroExamples(int32) (runs: 5107, μ: 4467, ~: 4467) LibDecimalFloatIsZeroTest:testNotIsZero(int224,int32) (runs: 5106, μ: 3922, ~: 3922) -LibDecimalFloatLog10Test:testLog10Packed(bytes32) (runs: 5106, μ: 1648425, ~: 1274576) +LibDecimalFloatLog10Test:testLog10Packed(bytes32) (runs: 5107, μ: 1648353, ~: 1274589) LibDecimalFloatLtTest:testLtExamples() (gas: 4015) LibDecimalFloatLtTest:testLtGasAZero() (gas: 967) LibDecimalFloatLtTest:testLtGasBZero() (gas: 1033) LibDecimalFloatLtTest:testLtGasBothZero() (gas: 959) LibDecimalFloatLtTest:testLtGasDifferentSigns() (gas: 1021) LibDecimalFloatLtTest:testLtGasExponentDiffOverflow() (gas: 1105) -LibDecimalFloatLtTest:testLtNegativeVsPositive(int256,int32,int256,int32) (runs: 5106, μ: 13801, ~: 13645) -LibDecimalFloatLtTest:testLtNegativeVsZero(int256,int32,int32) (runs: 5106, μ: 10810, ~: 11029) -LibDecimalFloatLtTest:testLtOneEAny(int224,int32) (runs: 5106, μ: 3930, ~: 3931) -LibDecimalFloatLtTest:testLtReference(bytes32,bytes32) (runs: 5106, μ: 4666, ~: 4998) -LibDecimalFloatLtTest:testLtVsEqualVsGt(bytes32,bytes32) (runs: 5106, μ: 4321, ~: 4210) -LibDecimalFloatLtTest:testLtX(int224) (runs: 5106, μ: 3823, ~: 3824) -LibDecimalFloatLtTest:testLtXEAnyVsXEAny(int256,int32,int32) (runs: 5106, μ: 10609, ~: 10349) -LibDecimalFloatLtTest:testLtXEAnyVsXEAnyNegative(int256,int32,int32) (runs: 5106, μ: 11205, ~: 11411) -LibDecimalFloatLtTest:testLtZero(int32,int32) (runs: 5106, μ: 4161, ~: 4161) +LibDecimalFloatLtTest:testLtNegativeVsPositive(int256,int32,int256,int32) (runs: 5107, μ: 13801, ~: 13645) +LibDecimalFloatLtTest:testLtNegativeVsZero(int256,int32,int32) (runs: 5107, μ: 10810, ~: 11029) +LibDecimalFloatLtTest:testLtOneEAny(int224,int32) (runs: 5107, μ: 3930, ~: 3931) +LibDecimalFloatLtTest:testLtReference(bytes32,bytes32) (runs: 5107, μ: 4666, ~: 4998) +LibDecimalFloatLtTest:testLtVsEqualVsGt(bytes32,bytes32) (runs: 5107, μ: 4321, ~: 4210) +LibDecimalFloatLtTest:testLtX(int224) (runs: 5107, μ: 3823, ~: 3824) +LibDecimalFloatLtTest:testLtXEAnyVsXEAny(int256,int32,int32) (runs: 5107, μ: 10609, ~: 10349) +LibDecimalFloatLtTest:testLtXEAnyVsXEAnyNegative(int256,int32,int32) (runs: 5107, μ: 11205, ~: 11411) +LibDecimalFloatLtTest:testLtZero(int32,int32) (runs: 5107, μ: 4161, ~: 4161) LibDecimalFloatLteTest:testLteGasAZero() (gas: 1018) LibDecimalFloatLteTest:testLteGasBZero() (gas: 1020) LibDecimalFloatLteTest:testLteGasBothZero() (gas: 748) LibDecimalFloatLteTest:testLteGasDifferentSigns() (gas: 1028) LibDecimalFloatLteTest:testLteGasExponentDiffOverflow() (gas: 1134) -LibDecimalFloatLteTest:testLteOneEAny(bytes32) (runs: 5106, μ: 3493, ~: 3493) -LibDecimalFloatLteTest:testLteReference(int224,int32,int224,int32) (runs: 5106, μ: 8161, ~: 6367) -LibDecimalFloatLteTest:testLteX(int224,int32) (runs: 5106, μ: 3929, ~: 3930) -LibDecimalFloatLteTest:testLteXEAnyVsXEAny(int256,int32,int32) (runs: 5106, μ: 10632, ~: 10373) -LibDecimalFloatLteTest:testLteXEAnyVsXEAnyNegative(int256,int32,int32) (runs: 5106, μ: 11228, ~: 11435) -LibDecimalFloatLteTest:testLteXNotLtY(bytes32,bytes32) (runs: 5106, μ: 3881, ~: 3807) -LibDecimalFloatLteTest:testLteXPositiveYNegative(int256,int32,int256,int32) (runs: 5106, μ: 13153, ~: 12983) -LibDecimalFloatLteTest:testLteXPositiveYZero(int256,int32,int32) (runs: 5106, μ: 9593, ~: 9212) -LibDecimalFloatLteTest:testLteZero(int32,int32) (runs: 5106, μ: 4806, ~: 4806) -LibDecimalFloatMaxTest:testMaxX(bytes32) (runs: 5106, μ: 4246, ~: 4246) -LibDecimalFloatMaxTest:testMaxXY(bytes32,bytes32) (runs: 5106, μ: 4689, ~: 4613) -LibDecimalFloatMaxTest:testMaxXYEqual(bytes32) (runs: 5106, μ: 5272, ~: 5272) -LibDecimalFloatMaxTest:testMaxXYGreater(bytes32,bytes32) (runs: 5103, μ: 6129, ~: 6016) +LibDecimalFloatLteTest:testLteOneEAny(bytes32) (runs: 5107, μ: 3493, ~: 3493) +LibDecimalFloatLteTest:testLteReference(int224,int32,int224,int32) (runs: 5107, μ: 8161, ~: 6367) +LibDecimalFloatLteTest:testLteX(int224,int32) (runs: 5107, μ: 3929, ~: 3930) +LibDecimalFloatLteTest:testLteXEAnyVsXEAny(int256,int32,int32) (runs: 5107, μ: 10632, ~: 10373) +LibDecimalFloatLteTest:testLteXEAnyVsXEAnyNegative(int256,int32,int32) (runs: 5107, μ: 11228, ~: 11435) +LibDecimalFloatLteTest:testLteXNotLtY(bytes32,bytes32) (runs: 5107, μ: 3881, ~: 3807) +LibDecimalFloatLteTest:testLteXPositiveYNegative(int256,int32,int256,int32) (runs: 5107, μ: 13153, ~: 12983) +LibDecimalFloatLteTest:testLteXPositiveYZero(int256,int32,int32) (runs: 5107, μ: 9593, ~: 9212) +LibDecimalFloatLteTest:testLteZero(int32,int32) (runs: 5107, μ: 4806, ~: 4806) +LibDecimalFloatMaxTest:testMaxX(bytes32) (runs: 5107, μ: 4246, ~: 4246) +LibDecimalFloatMaxTest:testMaxXY(bytes32,bytes32) (runs: 5107, μ: 4689, ~: 4613) +LibDecimalFloatMaxTest:testMaxXYEqual(bytes32) (runs: 5107, μ: 5272, ~: 5272) +LibDecimalFloatMaxTest:testMaxXYGreater(bytes32,bytes32) (runs: 5104, μ: 6129, ~: 6016) LibDecimalFloatMaxTest:testMaxXYLess(bytes32,bytes32) (runs: 5099, μ: 6141, ~: 6027) -LibDecimalFloatMinTest:testMinX(bytes32) (runs: 5106, μ: 4268, ~: 4268) -LibDecimalFloatMinTest:testMinXY(bytes32,bytes32) (runs: 5106, μ: 4689, ~: 4613) -LibDecimalFloatMinTest:testMinXYEqual(bytes32) (runs: 5106, μ: 5292, ~: 5292) -LibDecimalFloatMinTest:testMinXYGreater(bytes32,bytes32) (runs: 5101, μ: 6074, ~: 5961) +LibDecimalFloatMinTest:testMinX(bytes32) (runs: 5107, μ: 4268, ~: 4268) +LibDecimalFloatMinTest:testMinXY(bytes32,bytes32) (runs: 5107, μ: 4689, ~: 4613) +LibDecimalFloatMinTest:testMinXYEqual(bytes32) (runs: 5107, μ: 5292, ~: 5292) +LibDecimalFloatMinTest:testMinXYGreater(bytes32,bytes32) (runs: 5102, μ: 6074, ~: 5961) LibDecimalFloatMinTest:testMinXYLess(bytes32,bytes32) (runs: 5101, μ: 6087, ~: 5972) -LibDecimalFloatMinusTest:testMinusPacked(bytes32) (runs: 5106, μ: 5606, ~: 5607) +LibDecimalFloatMinusTest:testMinusPacked(bytes32) (runs: 5107, μ: 5606, ~: 5607) LibDecimalFloatMixedTest:testDiv1Over3Mixed() (gas: 11766) -LibDecimalFloatMulTest:testMulPacked(bytes32,bytes32) (runs: 5106, μ: 9690, ~: 10464) +LibDecimalFloatMulTest:testMulPacked(bytes32,bytes32) (runs: 5107, μ: 9690, ~: 10464) LibDecimalFloatPackTest:testPackExponentOverflow(int256,int256) (runs: 5105, μ: 11079, ~: 11267) LibDecimalFloatPackTest:testPackNegativeExponentLossyZero(int256,int256) (runs: 5105, μ: 11952, ~: 12110) -LibDecimalFloatPackTest:testPackZero(int256) (runs: 5106, μ: 4469, ~: 4469) -LibDecimalFloatPackTest:testPartsRoundTrip(int224,int32) (runs: 5106, μ: 5484, ~: 5485) -LibDecimalFloatPow10Test:testPow10Packed(bytes32) (runs: 5106, μ: 1644415, ~: 1259111) -LibDecimalFloatPowTest:testNegativePowError(bytes32,bytes32) (runs: 5106, μ: 1248827, ~: 1248862) -LibDecimalFloatPowTest:testPowAZero(int32,bytes32) (runs: 5102, μ: 1246465, ~: 1246465) +LibDecimalFloatPackTest:testPackZero(int256) (runs: 5107, μ: 4469, ~: 4469) +LibDecimalFloatPackTest:testPartsRoundTrip(int224,int32) (runs: 5107, μ: 5484, ~: 5485) +LibDecimalFloatPow10Test:testPow10Packed(bytes32) (runs: 5107, μ: 1643107, ~: 1259111) +LibDecimalFloatPowTest:testNegativePowError(bytes32,bytes32) (runs: 5107, μ: 1248827, ~: 1248862) +LibDecimalFloatPowTest:testPowAZero(int32,bytes32) (runs: 5103, μ: 1246465, ~: 1246465) LibDecimalFloatPowTest:testPowAZeroNegative(bytes32) (runs: 5097, μ: 1246849, ~: 1246849) -LibDecimalFloatPowTest:testPowBOne(bytes32) (runs: 5106, μ: 1551450, ~: 1551421) -LibDecimalFloatPowTest:testPowBZero(bytes32,int32) (runs: 5106, μ: 1246055, ~: 1246055) -LibDecimalFloatPowTest:testPows() (gas: 1325188) -LibDecimalFloatPowTest:testRoundTripFuzzPow(bytes32,bytes32) (runs: 5106, μ: 1266208, ~: 1261099) -LibDecimalFloatPowTest:testRoundTripSimple() (gas: 1670371) -LibDecimalFloatSqrtTest:testRoundTripFuzzSqrt(int224,int32) (runs: 5106, μ: 1305596, ~: 1309655) -LibDecimalFloatSqrtTest:testSqrt() (gas: 1300460) -LibDecimalFloatSqrtTest:testSqrtNegative(bytes32) (runs: 5106, μ: 1248766, ~: 1248834) -LibDecimalFloatSqrtTest:testSqrtRoundTrip() (gas: 1454891) -LibDecimalFloatSubTest:testSubPacked(bytes32,bytes32) (runs: 5106, μ: 12226, ~: 12283) +LibDecimalFloatPowTest:testPowBOne(bytes32) (runs: 5107, μ: 1551450, ~: 1551421) +LibDecimalFloatPowTest:testPowBZero(bytes32,int32) (runs: 5107, μ: 1246055, ~: 1246055) +LibDecimalFloatPowTest:testPows() (gas: 1325200) +LibDecimalFloatPowTest:testRoundTripFuzzPow(bytes32,bytes32) (runs: 5107, μ: 1266170, ~: 1261098) +LibDecimalFloatPowTest:testRoundTripSimple() (gas: 1670404) +LibDecimalFloatSqrtTest:testRoundTripFuzzSqrt(int224,int32) (runs: 5107, μ: 1305674, ~: 1309661) +LibDecimalFloatSqrtTest:testSqrt() (gas: 1300463) +LibDecimalFloatSqrtTest:testSqrtNegative(bytes32) (runs: 5107, μ: 1248766, ~: 1248834) +LibDecimalFloatSqrtTest:testSqrtRoundTrip() (gas: 1454921) +LibDecimalFloatSubTest:testSubPacked(bytes32,bytes32) (runs: 5107, μ: 12226, ~: 12283) LibFormatDecimalFloatCountSigFigs:testCountSigFigsExamples() (gas: 83596) -LibFormatDecimalFloatCountSigFigs:testCountSigFigsOne(int256) (runs: 5106, μ: 31878, ~: 31719) -LibFormatDecimalFloatCountSigFigs:testCountSigFigsZero(int256) (runs: 5106, μ: 3764, ~: 3764) +LibFormatDecimalFloatCountSigFigs:testCountSigFigsOne(int256) (runs: 5107, μ: 31874, ~: 31719) +LibFormatDecimalFloatCountSigFigs:testCountSigFigsZero(int256) (runs: 5107, μ: 3764, ~: 3764) LibFormatDecimalFloatToDecimalStringTest:testFormatDecimalCustomSigFigs() (gas: 26919) LibFormatDecimalFloatToDecimalStringTest:testFormatDecimalExamples() (gas: 976448) LibFormatDecimalFloatToDecimalStringTest:testFormatDecimalRoundTripExamples() (gas: 488510) -LibFormatDecimalFloatToDecimalStringTest:testFormatDecimalRoundTripNegative(int256,uint256) (runs: 5106, μ: 71432, ~: 73873) -LibFormatDecimalFloatToDecimalStringTest:testFormatDecimalRoundTripNonNegative(uint256,uint256) (runs: 5106, μ: 54969, ~: 47705) +LibFormatDecimalFloatToDecimalStringTest:testFormatDecimalRoundTripNegative(int256,uint256) (runs: 5107, μ: 71433, ~: 73873) +LibFormatDecimalFloatToDecimalStringTest:testFormatDecimalRoundTripNonNegative(uint256,uint256) (runs: 5107, μ: 54974, ~: 47705) LibLogTableBytesTest:testToBytesAntiLogTableDec() (gas: 159794) LibLogTableBytesTest:testToBytesAntiLogTableDecSmall() (gas: 162322) LibLogTableBytesTest:testToBytesLogTableDec() (gas: 143165) @@ -326,7 +333,7 @@ LibParseDecimalFloatTest:testParseLiteralDecimalFloatEDot() (gas: 4168) LibParseDecimalFloatTest:testParseLiteralDecimalFloatExponentRevert5() (gas: 4176) LibParseDecimalFloatTest:testParseLiteralDecimalFloatExponentRevert6() (gas: 4166) LibParseDecimalFloatTest:testParseLiteralDecimalFloatExponents() (gas: 402907) -LibParseDecimalFloatTest:testParseLiteralDecimalFloatFuzz(uint256,uint8,bool) (runs: 5106, μ: 46020, ~: 37187) +LibParseDecimalFloatTest:testParseLiteralDecimalFloatFuzz(uint256,uint8,bool) (runs: 5107, μ: 46025, ~: 37187) LibParseDecimalFloatTest:testParseLiteralDecimalFloatLeadingZeros() (gas: 59757) LibParseDecimalFloatTest:testParseLiteralDecimalFloatNegativeE() (gas: 6120) LibParseDecimalFloatTest:testParseLiteralDecimalFloatNegativeFrac() (gas: 5115) @@ -334,5 +341,5 @@ LibParseDecimalFloatTest:testParseLiteralDecimalFloatPrecisionRevert0() (gas: 27 LibParseDecimalFloatTest:testParseLiteralDecimalFloatPrecisionRevert1() (gas: 24934) LibParseDecimalFloatTest:testParseLiteralDecimalFloatSpecific() (gas: 22959) LibParseDecimalFloatTest:testParseLiteralDecimalFloatUnrelated() (gas: 51254) -LibParseDecimalFloatTest:testParsePacked(string) (runs: 5106, μ: 9811, ~: 9692) -TestDecimalFloatUnpackTest:testUnpackDeployed(bytes32) (runs: 5106, μ: 169646, ~: 169646) \ No newline at end of file +LibParseDecimalFloatTest:testParsePacked(string) (runs: 5107, μ: 9810, ~: 9692) +TestDecimalFloatUnpackTest:testUnpackDeployed(bytes32) (runs: 5107, μ: 169646, ~: 169646) \ No newline at end of file diff --git a/src/lib/implementation/LibDecimalFloatImplementation.sol b/src/lib/implementation/LibDecimalFloatImplementation.sol index f7ba8ede..6ec305ce 100644 --- a/src/lib/implementation/LibDecimalFloatImplementation.sol +++ b/src/lib/implementation/LibDecimalFloatImplementation.sol @@ -965,14 +965,14 @@ library LibDecimalFloatImplementation { return signedCoefficient; } else if (targetExponent > exponent) { int256 exponentDiff = targetExponent - exponent; - if (exponentDiff > 76 || exponentDiff < 0) { + if (exponentDiff > 76 || exponentDiff <= 0) { return (MAXIMIZED_ZERO_SIGNED_COEFFICIENT); } return signedCoefficient / int256(10 ** uint256(exponentDiff)); } else { int256 exponentDiff = exponent - targetExponent; - if (exponentDiff > 76 || exponentDiff < 0) { + if (exponentDiff > 76 || exponentDiff <= 0) { revert WithTargetExponentOverflow(signedCoefficient, exponent, targetExponent); } int256 scale = int256(10 ** uint256(exponentDiff)); From 93323b78a333a4b053c2d10ad32327e13e36122d Mon Sep 17 00:00:00 2001 From: David Meister Date: Sun, 21 Sep 2025 19:00:49 +0400 Subject: [PATCH 5/6] Update test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../LibDecimalFloatImplementation.withTargetExponent.t.sol | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol b/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol index 1b399d06..3a863a6c 100644 --- a/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol +++ b/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol @@ -110,11 +110,6 @@ contract LibDecimalFloatImplementationWithTargetExponentTest is Test { checkWithTargetExponent(type(int256).max, 0, 1, type(int256).max / 10); } - function testWithTargetExponentExponentEqual(int256 signedCoefficient, int256 exponent) external pure { - int256 actualSignedCoefficient = - LibDecimalFloatImplementation.withTargetExponent(signedCoefficient, exponent, exponent); - assertEq(actualSignedCoefficient, signedCoefficient, "signedCoefficient"); - } function testWithTargetExponentTargetMoreThan76Larger( int256 signedCoefficient, From 0b729476c7e6c060b317b6c0ee4648631ad370cf Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Sun, 21 Sep 2025 19:26:14 +0400 Subject: [PATCH 6/6] fmt --- .../LibDecimalFloatImplementation.withTargetExponent.t.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol b/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol index 3a863a6c..ffa2f827 100644 --- a/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol +++ b/test/src/lib/implementation/LibDecimalFloatImplementation.withTargetExponent.t.sol @@ -110,7 +110,6 @@ contract LibDecimalFloatImplementationWithTargetExponentTest is Test { checkWithTargetExponent(type(int256).max, 0, 1, type(int256).max / 10); } - function testWithTargetExponentTargetMoreThan76Larger( int256 signedCoefficient, int256 exponent,