Compare commits

...

9 Commits

Author SHA1 Message Date
RichardAH
2ec0683902 Update applyHook.cpp 2024-11-09 14:45:53 +10:00
RichardAH
91cc584e6d Merge branch 'dev' into fix-float 2024-11-09 14:34:27 +10:00
RichardAH
638a2ba34a Update applyHook.cpp
clang
2024-11-09 14:23:43 +10:00
RichardAH
8cf6bfcef9 Update applyHook.cpp 2024-11-09 14:20:23 +10:00
RichardAH
c9d57adc83 Update Feature.h 2024-11-09 14:19:48 +10:00
RichardAH
762d8e74a1 Update Feature.cpp 2024-11-09 14:19:17 +10:00
Denis Angell
610c0ca40f [fold] add amendment 2024-10-31 11:37:04 +01:00
RichardAH
4e0b11fa1b Merge branch 'dev' into fix-float 2024-10-25 10:11:41 +10:00
Denis Angell
b0698053f6 fix rounding error 2024-08-19 15:03:54 +02:00
3 changed files with 19 additions and 6 deletions

View File

@@ -5404,7 +5404,7 @@ DEFINE_HOOK_FUNCTION(
const int64_t float_one_internal = make_float(1000000000000000ull, -15, false);
inline int64_t
float_divide_internal(int64_t float1, int64_t float2)
float_divide_internal(int64_t float1, int64_t float2, bool hasFix)
{
RETURN_IF_INVALID_FLOAT(float1);
RETURN_IF_INVALID_FLOAT(float2);
@@ -5457,8 +5457,16 @@ float_divide_internal(int64_t float1, int64_t float2)
while (man2 > 0)
{
int i = 0;
for (; man1 > man2; man1 -= man2, ++i)
;
if (hasFix)
{
for (; man1 >= man2; man1 -= man2, ++i)
;
}
else
{
for (; man1 > man2; man1 -= man2, ++i)
;
}
man3 *= 10;
man3 += i;
@@ -5478,7 +5486,8 @@ DEFINE_HOOK_FUNCTION(int64_t, float_divide, int64_t float1, int64_t float2)
HOOK_SETUP(); // populates memory_ctx, memory, memory_length, applyCtx,
// hookCtx on current stack
return float_divide_internal(float1, float2);
bool const hasFix = view.rules().enabled(fixFloatDivide);
return float_divide_internal(float1, float2, hasFix);
HOOK_TEARDOWN();
}
@@ -5497,7 +5506,9 @@ DEFINE_HOOK_FUNCTION(int64_t, float_invert, int64_t float1)
return DIVISION_BY_ZERO;
if (float1 == float_one_internal)
return float_one_internal;
return float_divide_internal(float_one_internal, float1);
bool const fixV3 = view.rules().enabled(fixFloatDivide);
return float_divide_internal(float_one_internal, float1, fixV3);
HOOK_TEARDOWN();
}

View File

@@ -74,7 +74,7 @@ namespace detail {
// Feature.cpp. Because it's only used to reserve storage, and determine how
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
// the actual number of amendments. A LogicError on startup will verify this.
static constexpr std::size_t numFeatures = 73;
static constexpr std::size_t numFeatures = 74;
/** Amendments that this server supports and the default voting behavior.
Whether they are enabled depends on the Rules defined in the validated
@@ -361,6 +361,7 @@ extern uint256 const fixNSDelete;
extern uint256 const fix240819;
extern uint256 const fixPageCap;
extern uint256 const fix240911;
extern uint256 const fixFloatDivide;
} // namespace ripple

View File

@@ -467,6 +467,7 @@ REGISTER_FIX (fixNSDelete, Supported::yes, VoteBehavior::De
REGISTER_FIX (fix240819, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fixPageCap, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fix240911, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fixFloatDivide, Supported::yes, VoteBehavior::DefaultYes);
// The following amendments are obsolete, but must remain supported
// because they could potentially get enabled.