Skip to content

float struct#24

Merged
thedavidmeister merged 4 commits intomainfrom
2025-03-28-float-mem
Apr 1, 2025
Merged

float struct#24
thedavidmeister merged 4 commits intomainfrom
2025-03-28-float-mem

Conversation

@thedavidmeister
Copy link
Copy Markdown
Contributor

@thedavidmeister thedavidmeister commented Mar 28, 2025

Motivation

Solution

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • New Features

    • The library now offers a streamlined decimal arithmetic interface that uses a unified numerical type, allowing operations such as addition, subtraction, multiplication, division, conversion, and more to be performed with a single structured input.
    • New external functions for absolute value, power, logarithm, and comparison operations have been added, enhancing flexibility in handling decimal floats.
  • Tests

    • Expanded testing validates consistent behavior, robust error handling, and improved reliability across all arithmetic and conversion operations, including new tests for packing and unpacking float representations.

This update simplifies usage and enhances overall robustness for decimal computations.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 28, 2025

Walkthrough

The changes introduce a new Float struct in the LibDecimalFloat library to encapsulate a signed coefficient and an exponent. Several internal functions have been modified or added to accept the struct instead of separate parameters. Additionally, new external wrapper functions have been implemented in the test contracts for operations such as abs, add, sub, multiply, divide, and others. These wrappers support both raw integer inputs and the new Float struct. Tests have been updated to validate memory-based operations and error handling using try-catch blocks.

Changes

File Change Summary
src/lib/LibDecimalFloat.sol Introduced new Float struct with signedCoefficient and exponent. Added/modified functions: fromFixedDecimalLossyMem, fromFixedDecimalLosslessMem, toFixedDecimalLossy, toFixedDecimalLossless, pack, unpackMem, add, sub, minus, abs, multiply, divide, inv, eq, lt, gt, frac, floor, power10, log10, and power to operate on the struct.
test/src/lib/LibDecimalFloat.{abs,add,decimal,decimalLossless,divide,eq,floor,frac,gt,inv,log10,lt,minus,multiply,pack,power,power10,sub}.t.sol Added external wrapper functions that accept both separate integer values and Float structs for each operation. Introduced new test functions that validate memory-based operations and error handling (using try-catch) for functions such as abs, add, subtract, multiply, divide, and more. Also added using LibDecimalFloat for Float; directives where appropriate.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant TestContract
    participant LibDecimalFloat
    Client->>TestContract: Call operationExternal(signedCoefficientA, exponentA, signedCoefficientB, exponentB)
    TestContract->>LibDecimalFloat: Invoke operation using raw integer parameters
    LibDecimalFloat-->>TestContract: Return (int256, int256) result
    TestContract-->>Client: Return result
Loading
sequenceDiagram
    participant Client
    participant TestContract
    participant LibDecimalFloat
    Client->>TestContract: Call operationExternal(FloatA, FloatB)
    TestContract->>LibDecimalFloat: Invoke operation using Float struct
    LibDecimalFloat-->>TestContract: Return Float result
    TestContract-->>Client: Return result
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8da7820 and d984580.

📒 Files selected for processing (4)
  • test/src/lib/LibDecimalFloat.abs.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.eq.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.frac.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.lt.t.sol (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-test)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-static)
  • GitHub Check: git-clean
🔇 Additional comments (4)
test/src/lib/LibDecimalFloat.abs.t.sol (1)

6-32: Well-implemented Float struct wrapper and testing!

The Float struct implementation for the absolute value calculation is well-designed. The test correctly verifies that the stack-based and memory-based implementations produce identical results, and the error handling through try-catch blocks is appropriate.

test/src/lib/LibDecimalFloat.eq.t.sol (1)

4-34: Clean and consistent Float struct implementation for equality checks

The equality check implementation with Float structs maintains the same pattern used across other test files. The test properly verifies that stack-based and memory-based implementations produce identical results, with appropriate error handling.

test/src/lib/LibDecimalFloat.lt.t.sol (1)

4-34: Consistent Float struct implementation for less-than comparison

The less-than comparison implementation with Float structs follows the same pattern as other test files, ensuring consistency throughout the codebase. The test correctly verifies equivalence between stack-based and memory-based implementations.

test/src/lib/LibDecimalFloat.frac.t.sol (1)

4-31: Well-structured Float struct implementation for fractional part calculation

The fractional part calculation implementation with Float structs maintains the consistent pattern seen across all test files. The test correctly verifies equivalence between stack-based and memory-based implementations with proper error handling.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d24cdc3 and cfab79e.

📒 Files selected for processing (19)
  • src/lib/LibDecimalFloat.sol (22 hunks)
  • test/src/lib/LibDecimalFloat.abs.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.add.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.decimal.t.sol (2 hunks)
  • test/src/lib/LibDecimalFloat.decimalLossless.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.divide.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.eq.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.floor.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.frac.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.gt.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.inv.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.log10.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.lt.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.minus.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.multiply.t.sol (2 hunks)
  • test/src/lib/LibDecimalFloat.pack.t.sol (2 hunks)
  • test/src/lib/LibDecimalFloat.power.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.power10.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.sub.t.sol (1 hunks)
🔇 Additional comments (88)
test/src/lib/LibDecimalFloat.inv.t.sol (3)

5-5: Properly introducing the Float struct

These changes correctly import the Float struct and enable the use of library functions on it with the using directive. This is a well-structured approach to implementing the new float struct pattern.

Also applies to: 9-9


11-17: Good implementation of external wrapper functions

The overloaded function pattern here is well implemented:

  1. First overload accepts traditional raw integer parameters
  2. Second overload works with the new Float struct

This approach maintains backward compatibility while introducing the new struct-based API.


20-31: Well-structured test for memory operations

The test function properly validates that both implementations (raw integers vs. Float struct) produce the same results. The try-catch pattern effectively handles both success and error cases:

  1. For successful calls, it verifies that both implementations return the same values
  2. For failing calls, it verifies that both implementations fail with the same error

This is a robust approach to ensure consistent behavior.

test/src/lib/LibDecimalFloat.floor.t.sol (3)

4-4: Consistent implementation of Float struct imports

These lines correctly import the Float struct and set up the contract to use library functions with the using directive, following the same pattern as the other updated files.

Also applies to: 9-9


11-17: Good implementation of overloaded external wrapper functions

The floor operation follows the same pattern as other operations by:

  1. Providing an overload that works with raw integer parameters
  2. Adding a new overload that accepts the Float struct

This consistent pattern across operations makes the API more cohesive and predictable.


20-31: Thorough memory-based test implementation

This test function correctly verifies that the behavior of the struct-based implementation matches that of the integer-based implementation:

  • Success cases check that both implementations return the same values
  • Failure cases ensure that both implementations revert with the same error

This rigorous testing approach helps ensure consistent behavior across both API styles.

test/src/lib/LibDecimalFloat.minus.t.sol (3)

4-4: Renaming and proper struct setup

The contract has been renamed from LibDecimalFloatSubTest to LibDecimalFloatMinusTest, which better aligns with the function name (minus). The import and using directive correctly set up the contract to work with the Float struct.

Also applies to: 9-10


12-18: Consistent implementation of external wrappers

These external wrapper functions follow the same overloading pattern seen in other operations:

  1. One version that works with raw integers
  2. A second version that accepts the Float struct

This consistent approach across operations creates a predictable API.


21-32: Well-structured memory test implementation

The test function successfully validates that both implementation styles produce identical results:

  • For successful operations, it confirms matching return values
  • For failing operations, it verifies identical error behavior

This testing pattern is consistently applied across all operations, which is excellent for ensuring API consistency.

test/src/lib/LibDecimalFloat.abs.t.sol (3)

6-6: Properly introducing the Float struct

The import and using directive are correctly implemented to bring in the Float struct and enable the use of library functions on it, consistent with the approach in other files.

Also applies to: 9-9


11-17: Good implementation of external wrapper functions

These wrapper functions implement the consistent pattern of providing:

  1. A traditional function that accepts raw integer parameters
  2. An overloaded function that works with the new Float struct

This approach maintains backward compatibility while adding the new struct-based API.


20-31: Thorough test for memory operations

The test function correctly verifies that both API styles (raw integers vs. Float struct) produce the same results:

  • Success cases have matching return values
  • Failure cases revert with the same error

This consistent testing approach across all modified files ensures that the Float struct behaves identically to the original implementation.

test/src/lib/LibDecimalFloat.frac.t.sol (3)

4-10: Import and usage directive look good

The code properly imports the new Float struct from the library and adds the appropriate using directive to enable the use of library functions directly on Float types.


11-17: External wrappers properly implemented

The two overloaded fracExternal functions provide a clean interface for testing both the original parameter-based approach and the new struct-based approach.


20-31: Test function well-structured with proper error handling

The testFracMem function correctly tests both parameter-based and struct-based approaches, ensuring they return the same results. The try-catch block properly handles potential reverts, which is a good practice.

test/src/lib/LibDecimalFloat.sub.t.sol (3)

4-10: Import and usage directive look good

The code properly imports the new Float struct along with required constants from the library and adds the appropriate using directive.


12-22: External wrappers properly implemented

Both versions of the subExternal function are properly implemented, maintaining backward compatibility while supporting the new struct-based approach.


25-36: Test function well-structured

The testSubMem function correctly tests both parameter-based and struct-based approaches, with proper error handling using try-catch.

test/src/lib/LibDecimalFloat.lt.t.sol (3)

4-12: Import and usage directive look good

The code properly imports the new Float struct from the library and adds the appropriate using directive.


13-23: External wrappers properly implemented

Both versions of the ltExternal function are correctly implemented to support testing of both parameter-based and struct-based approaches.


26-34: Test function well-structured

The testLtMem function correctly tests both parameter-based and struct-based approaches, with proper error handling using try-catch.

test/src/lib/LibDecimalFloat.eq.t.sol (3)

4-12: Import and usage directive look good

The code properly imports the new Float struct from the library and adds the appropriate using directive.


13-23: External wrappers properly implemented

Both versions of the eqExternal function are correctly implemented to support testing of both parameter-based and struct-based approaches.


26-34: Test function well-structured

The testEqMem function correctly tests both parameter-based and struct-based approaches, with proper error handling using try-catch.

test/src/lib/LibDecimalFloat.divide.t.sol (5)

5-5: Import properly updated to include the new Float struct.

The import statement is correctly updated to include the new Float struct type along with existing imports.


10-10: Good use of the using directive for Float.

Adding the using LibDecimalFloat for Float; directive enables direct method calls on Float instances, improving code readability.


12-18: Well-implemented external wrapper for divide operation.

This external function provides a clean interface for testing the divide operation with separate coefficient and exponent parameters. The implementation correctly delegates to the LibDecimalFloat library method.


20-22: Good implementation of struct-based divide wrapper.

This overloaded function accepts Float structs and properly extracts their components to call the divide operation, enhancing the API ergonomics.


25-36: Well-designed memory test with proper error handling.

The test function effectively validates that both parameter-based and struct-based divide operations produce identical results. The try-catch block properly handles error cases by expecting the same error when calling the struct-based function.

test/src/lib/LibDecimalFloat.add.t.sol (5)

4-4: Import correctly updated to include Float struct.

The import statement properly includes the Float struct along with other constants from LibDecimalFloat.


10-10: Appropriate use of the using directive.

The using LibDecimalFloat for Float; directive enables method-style invocation on Float instances, improving code readability.


12-18: Well-implemented external wrapper for add operation.

This function provides a clean testing interface for the add operation with separate coefficient and exponent parameters, correctly delegating to the library implementation.


20-22: Consistent implementation of the struct-based add wrapper.

This function maintains consistency with other operations by extracting components from Float structs to call the add operation.


25-36: Thorough test with proper error propagation.

The test function effectively validates that both parameter-based and struct-based add operations produce identical results. The try-catch block correctly handles potential errors by expecting the same error when calling the struct-based method.

test/src/lib/LibDecimalFloat.log10.t.sol (5)

4-4: Import statement properly updated for Float type.

The import statement is correctly modified to include the Float struct type.


10-10: Good use of the using directive for Float.

Adding the using LibDecimalFloat for Float; directive enables fluent method calls on Float instances.


12-15: Well-implemented external wrapper for log10 operation.

This function correctly implements the log10 operation wrapper for coefficient and exponent parameters, including obtaining the required log tables.


17-20: Good implementation of struct-based log10 wrapper.

This function maintains API consistency by providing a struct-based interface for the log10 operation.


23-34: Thorough test with proper error handling.

The test function effectively validates that both parameter-based and struct-based log10 operations produce identical results. The error handling is implemented correctly to verify consistent behavior in error cases.

test/src/lib/LibDecimalFloat.power10.t.sol (5)

4-4: Import correctly updated to include Float struct.

The import statement is properly updated to include the Float struct type.


10-10: Appropriate use of the using directive.

The using LibDecimalFloat for Float; directive enables method-style invocation on Float instances.


12-15: Well-implemented external wrapper for power10 operation.

This function provides a clean interface for testing the power10 operation with separate coefficient and exponent parameters, including proper log table acquisition.


17-20: Consistent implementation of struct-based power10 wrapper.

This function maintains API consistency by providing a struct-based interface for the power10 operation.


23-34: Thorough test with proper error handling.

The test function effectively validates that both parameter-based and struct-based power10 operations produce identical results. The error handling properly ensures consistent behavior in error scenarios.

test/src/lib/LibDecimalFloat.power.t.sol (3)

6-12: Good addition of Float struct support.

The import and using directive correctly enable the use of the new Float struct type with the LibDecimalFloat library functions.


13-22: Well-structured function overloading for both stack and struct parameters.

These two powerExternal function overloads handle both traditional parameter passing (explicit coefficient and exponent values) and the new struct-based approach. This maintains backward compatibility while enhancing the API.


24-36: Good test structure for the memory version.

This test function appropriately validates that both the stack-based and memory-based implementations produce identical results or fail with the same error message. The try-catch pattern effectively handles both successful calculations and error conditions.

test/src/lib/LibDecimalFloat.gt.t.sol (3)

4-12: Good addition of Float struct support.

The import statement now includes the Float type, and the using directive enables direct use of LibDecimalFloat functions on Float instances.


13-23: Well-structured function overloading for comparison operations.

The two gtExternal function overloads provide a clean interface for both the traditional parameter approach and the new struct-based approach, allowing for flexible usage in different contexts.


26-34: Comprehensive test for memory-based comparisons.

This test function effectively validates that both versions of the greater-than comparison produce identical results or fail with the same error. The try-catch pattern handles both success and error scenarios appropriately.

test/src/lib/LibDecimalFloat.decimal.t.sol (4)

9-11: Good addition of Float struct support.

The import has been updated to include the Float type and NegativeFixedDecimalConversion error, and the using directive enables calling LibDecimalFloat functions directly on Float instances.

Also applies to: 17-18


27-29: Well-structured function overloading for decimal conversions.

This function provides a clear interface for converting Float memory instances to fixed decimal representations, complementing the existing stack-based version.


31-40: Solid test for fromFixedDecimalLossyMem function.

This test function ensures that both the stack and memory versions of the fromFixedDecimalLossy function produce the same results, validating consistency across the different implementations.


42-55: Comprehensive test for toFixedDecimalLossy with Float struct.

This test function thoroughly validates that both the stack and memory versions of toFixedDecimalLossy produce identical results or fail with the same error, ensuring consistency across implementations.

test/src/lib/LibDecimalFloat.multiply.t.sol (3)

5-9: Good addition of Float struct support.

The import has been updated to include the Float type, and the using directive enables calling LibDecimalFloat functions directly on Float instances.

Also applies to: 20-21


22-32: Well-structured function overloading for multiplication operations.

These two multiplyExternal function overloads provide a clean interface for both stack-based and struct-based approaches, maintaining compatibility while enhancing the API ergonomics.


34-46: Thorough test for memory-based multiplication.

This test function effectively ensures that both versions of the multiplication function produce identical results or fail with the same error. The try-catch pattern appropriately handles both success and error scenarios.

test/src/lib/LibDecimalFloat.decimalLossless.t.sol (5)

15-15: Good use of using directive.

The using LibDecimalFloat for Float directive enables calling methods directly on Float types, making the test code more concise and readable. This is a clean way to use the new struct type.


21-23: Well-structured memory wrapper.

This external wrapper provides a clean interface for the memory-based version of fromFixedDecimalLossless. It's consistent with the existing stack-based wrapper pattern.


33-35: Good memory-based struct interface.

The memory-based wrapper function uses the Float struct property directly with the toFixedDecimalLossless method, which demonstrates the benefits of the struct-based approach in simplifying the API.


37-49: Comprehensive test for the memory version.

This test ensures that the memory version of fromFixedDecimalLossless behaves exactly like the stack version. The test properly handles error cases and validates all aspects of the function's behavior.


51-63: Well-implemented memory version test with error handling.

This test effectively validates the memory version of toFixedDecimalLossless against the stack version, including proper error handling with try-catch blocks. This approach ensures that both versions behave identically in all scenarios.

test/src/lib/LibDecimalFloat.pack.t.sol (4)

16-22: Clean implementation of packing functions.

Both implementations of packExternal are well-designed - one accepting separate parameters and one accepting a Float struct. This provides a complete test surface for the pack functionality.


24-30: Good pair of unpacking functions.

The implementation of both unpackExternal and unpackMemExternal provides a comprehensive test surface for unpacking functionality - one returning separate parameters and one returning a Float struct.


53-62: Thorough testing of pack memory version.

This test validates that the memory and stack versions of pack behave identically, including proper error handling. The test ensures both versions produce the same output or fail in the same way.


64-74: Comprehensive unpack memory test.

This test ensures that the memory and stack versions of unpack behave identically, with proper error handling. The assertion of both coefficient and exponent values provides complete validation.

src/lib/LibDecimalFloat.sol (22)

41-44: Great addition of the Float struct.

The Float struct elegantly encapsulates the two core components (signedCoefficient and exponent) that were previously passed separately throughout the library. This improves code organization and readability.


119-134: Well-documented memory version.

The memory version function is well-documented with clear explanations of its purpose and benefits. The implementation correctly delegates to the existing function while returning the struct. The explicit mention of gas costs and stack depth mitigation is valuable for users.


150-158: Consistent implementation pattern.

This memory-based version follows the same pattern as the other memory functions, correctly delegating to the original function and packaging the results in a Float struct. The consistent approach makes the codebase more maintainable.


235-247: Clean struct-based implementation.

This function provides a cleaner interface by accepting a Float struct while maintaining the same behavior by delegating to the original function. The documentation clearly explains the trade-offs between the two versions.


267-278: Consistency in API design.

The memory version of toFixedDecimalLossless maintains consistency with the other memory functions, providing the same benefits of improved ergonomics and stack depth mitigation.


304-306: Concise pack implementation.

The implementation of pack for the Float struct is clean and minimal, correctly delegating to the existing function with the appropriate parameters.


324-326: Efficient unpack implementation.

The memory-based unpackMem function correctly unpacks a PackedFloat into a Float struct, providing a convenient API for callers.


449-459: Well-structured add implementation.

This memory-based version of add maintains consistency with the original function while providing a cleaner interface. The struct-based approach reduces the number of parameters, improving readability.


482-492: Consistent sub implementation.

The memory-based sub function follows the same pattern as the other memory functions, making the API consistent and predictable.


526-533: Clean minus implementation.

The implementation of minus for the Float struct continues the consistent pattern established throughout the library.


554-561: Consistent abs implementation.

The memory-based abs function follows the same implementation pattern as the other memory functions, contributing to a coherent API.


618-628: Well-structured multiply implementation.

The multiply function for Float structs follows the established pattern, correctly delegating to the original function with the appropriate parameters.


695-705: Consistent divide implementation.

The memory-based divide function maintains consistency with the other memory functions, providing the same benefits of improved ergonomics and stack depth mitigation.


717-724: Clear inv implementation.

The memory-based inv function follows the same implementation pattern as the other memory functions, contributing to a coherent API.


750-759: Consistent eq implementation.

The memory-based eq function follows the same pattern as the other memory functions, making the API consistent and predictable.


785-794: Well-structured lt implementation.

The implementation of lt for the Float struct continues the consistent pattern established throughout the library.


820-829: Consistent gt implementation.

The memory-based gt function follows the same pattern as the other memory functions, contributing to a coherent API.


845-852: Clear frac implementation.

The memory-based frac function maintains consistency with the other memory functions, providing the same benefits of improved ergonomics and stack depth mitigation.


868-875: Consistent floor implementation.

The memory-based floor function follows the same implementation pattern as the other memory functions, making the API clean and predictable.


927-937: Well-structured power10 implementation.

The implementation of power10 for the Float struct follows the consistent pattern established throughout the library.


1049-1058: Clean log10 implementation.

The memory-based log10 function maintains consistency with the other memory functions, providing the same benefits of improved ergonomics and stack depth mitigation.


1088-1104: Consistent power implementation.

The memory-based power function nicely completes the set of memory-based functions, following the same pattern established throughout the library for a coherent API.

Comment thread test/src/lib/LibDecimalFloat.inv.t.sol
Comment thread test/src/lib/LibDecimalFloat.floor.t.sol
Comment thread test/src/lib/LibDecimalFloat.minus.t.sol
Comment thread test/src/lib/LibDecimalFloat.abs.t.sol Outdated
Comment thread test/src/lib/LibDecimalFloat.frac.t.sol Outdated
Comment thread test/src/lib/LibDecimalFloat.sub.t.sol Outdated
Comment thread test/src/lib/LibDecimalFloat.lt.t.sol Outdated
Comment thread test/src/lib/LibDecimalFloat.eq.t.sol Outdated
thedavidmeister and others added 3 commits April 1, 2025 20:58
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@thedavidmeister thedavidmeister merged commit dd55d6f into main Apr 1, 2025
4 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Apr 7, 2025
4 tasks
This was referenced Apr 15, 2025
@coderabbitai coderabbitai Bot mentioned this pull request May 10, 2025
4 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Jul 29, 2025
4 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Aug 11, 2025
Merged
4 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Feb 4, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants