Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/float/abi/DecimalFloat.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/lib/deploy/LibDecimalFloatDeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ library LibDecimalFloatDeploy {
/// @dev Address of the DecimalFloat contract deployed via Zoltu's
/// deterministic deployment proxy.
/// This address is the same across all EVM-compatible networks.
address constant ZOLTU_DEPLOYED_DECIMAL_FLOAT_ADDRESS = address(0x799632d282178e770C7465cad54aDA1021A913D6);
address constant ZOLTU_DEPLOYED_DECIMAL_FLOAT_ADDRESS = address(0x9b0eF7FbDF04b3A58989860Dea0534C978d64464);

/// @dev The expected codehash of the DecimalFloat contract deployed via
/// Zoltu's deterministic deployment proxy.
bytes32 constant DECIMAL_FLOAT_CONTRACT_HASH = 0xdc468883c345d41c0abd98ef2fd933c370bd1682522d37e6f6b729793301f55e;
bytes32 constant DECIMAL_FLOAT_CONTRACT_HASH = 0x369ac78d686dfdf1d41771dc7bf321dcd339b0a454dc9cf6c37eff579c3a0c3a;

/// @dev Deploy constants pinned to each version published to the soldeer
/// registry. These are frozen literals — not aliases of the "current"
Expand Down
7 changes: 7 additions & 0 deletions src/lib/parse/LibParseDecimalFloat.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {LibParseChar} from "rain-string-0.2.0/src/lib/parse/LibParseChar.sol";
import {
CMASK_NUMERIC_0_9,
CMASK_NEGATIVE_SIGN,
CMASK_PLUS_SIGN,
CMASK_E_NOTATION,
CMASK_ZERO,
CMASK_DECIMAL_POINT
Expand Down Expand Up @@ -142,6 +143,12 @@ library LibParseDecimalFloat {
cursor++;
uint256 eStart = cursor;
cursor = LibParseChar.skipMask(cursor, end, CMASK_NEGATIVE_SIGN);
// Skip an optional explicit positive sign (e.g. 1e+2). Advance
// eStart past it so the int parser only sees the digit string.
if (LibParseChar.isMask(cursor, end, CMASK_PLUS_SIGN) == 1) {
cursor++;
eStart = cursor;
}
{
uint256 digitsStart = cursor;
cursor = LibParseChar.skipMask(cursor, end, CMASK_NUMERIC_0_9);
Expand Down
19 changes: 19 additions & 0 deletions test/src/lib/parse/LibParseDecimalFloat.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,25 @@ contract LibParseDecimalFloatTest is Test {
checkParseDecimalFloatFail("e.", ParseEmptyDecimalString.selector, 0);
}

/// Explicit positive exponent sign is accepted and equivalent to no sign.
function testParseLiteralDecimalFloatPositiveExponentSign() external pure {
checkParseDecimalFloat("1e+2", 1, 2, 4);
checkParseDecimalFloat("1.0e+2", 1, 2, 6);
checkParseDecimalFloat("1E+2", 1, 2, 4);
checkParseDecimalFloat("0e+0", 0, 0, 4);
checkParseDecimalFloat("0e+1", 0, 0, 4);
checkParseDecimalFloat("1e+0", 1, 0, 4);
checkParseDecimalFloat("1e+260", 1, 260, 6);
checkParseDecimalFloat("-1e+2", -1, 2, 5);
checkParseDecimalFloat("1.1e+1", 11, 0, 6);
}

/// Positive sign with no digits is still an error.
function testParseLiteralDecimalFloatPositiveENoDigits() external pure {
checkParseDecimalFloatFail("1e+", MalformedExponentDigits.selector, 3);
checkParseDecimalFloatFail("0.0e+", MalformedExponentDigits.selector, 5);
}

/// Negative e with no digits is an error.
function testParseLiteralDecimalFloatNegativeE() external pure {
checkParseDecimalFloatFail("0.0e-", MalformedExponentDigits.selector, 5);
Expand Down
Loading