Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixUniversalNumber: Number merge #4192

Merged
merged 13 commits into from
Feb 7, 2023
Merged

Commits on Feb 7, 2023

  1. Configuration menu
    Copy the full SHA
    4e61fe9 View commit details
    Browse the repository at this point in the history
  2. Add conversions between Number, XRPAmount and int64_t

    * Conversions to Number are implicit
    * Conversions away from Number are explicit and potentially lossy
    * If lossy, round to nearest, and to even on tie
    HowardHinnant committed Feb 7, 2023
    Configuration menu
    Copy the full SHA
    407f041 View commit details
    Browse the repository at this point in the history
  3. Add clip

    * Return 0 if abs(x) < limit, else returns x
    HowardHinnant committed Feb 7, 2023
    Configuration menu
    Copy the full SHA
    5744b37 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    eb0774d View commit details
    Browse the repository at this point in the history
  5. Add tests

    HowardHinnant committed Feb 7, 2023
    Configuration menu
    Copy the full SHA
    77d9a3d View commit details
    Browse the repository at this point in the history
  6. Use Number for IOUAmount and STAmount arithmetic

    * Guarded by amendment fixUniversalNumber
    * Produces slightly better accuracy in some computations.
    HowardHinnant committed Feb 7, 2023
    Configuration menu
    Copy the full SHA
    1746e28 View commit details
    Browse the repository at this point in the history
  7. Introduce rounding modes for Number:

    You can set a thread-local flag to direct Number how to round
    non-exact results with the syntax:
    
        Number::rounding_mode prev_mode = Number::setround(Number::towards_zero);
    
    This flag will stay in effect for this thread only until another call
    to setround.  The previously set rounding mode is returned.
    
    You can also retrieve the current rounding mode with:
    
        Number::rounding_mode current_mode = Number::getround();
    
    The available rounding modes are:
    
    * to_nearest : Rounds to nearest representable value.  On tie, rounds
                   to even.
    * towards_zero : Rounds towards zero.
    * downward : Rounds towards negative infinity.
    * upward : Rounds towards positive infinity.
    
    The default rounding mode is to_nearest.
    HowardHinnant committed Feb 7, 2023
    Configuration menu
    Copy the full SHA
    868109d View commit details
    Browse the repository at this point in the history
  8. Silence warnings

    HowardHinnant committed Feb 7, 2023
    Configuration menu
    Copy the full SHA
    6272a34 View commit details
    Browse the repository at this point in the history
  9. Remove undefined behavior

    * Taking the negative of a signed negative is UB, but
      taking the negative of an unsigned is not.
    HowardHinnant committed Feb 7, 2023
    Configuration menu
    Copy the full SHA
    5733ff4 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    bd97fb5 View commit details
    Browse the repository at this point in the history
  11. Replace Number division algorithm

    * Replace division with faster algorithm.
    * Correct some rounding bugs in multiplication.
    * Add tests for rounding bugs.
    HowardHinnant committed Feb 7, 2023
    Configuration menu
    Copy the full SHA
    25c0589 View commit details
    Browse the repository at this point in the history
  12. Optimize uint128_t division by 10 within Number.cpp

    * Optimization includes computing remainder from division.
    * Used only within Number::operator*=.
    HowardHinnant committed Feb 7, 2023
    Configuration menu
    Copy the full SHA
    c954a85 View commit details
    Browse the repository at this point in the history
  13. Introduce min/max observers for Number

    Three static member functions are introduced with
    definitions consistent with std::numeric_limits:
    
    static constexpr Number min() noexcept;
    
      Returns: The minimum positive value.  This is the value closest to zero.
    
    static constexpr Number max() noexcept;
    
      Returns: The maximum possible value.
    
    static constexpr Number lowest() noexcept;
    
      Returns: The negative value which is less than all other values.
    HowardHinnant committed Feb 7, 2023
    Configuration menu
    Copy the full SHA
    ff1495b View commit details
    Browse the repository at this point in the history