mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
LibCrypto: Convert BigFraction stringification to String
This commit is contained in:
parent
5cfd50224c
commit
e6c96ce57e
Notes:
github-actions[bot]
2024-12-04 13:02:44 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/e6c96ce57e3 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2731 Reviewed-by: https://github.com/shannonbooth
3 changed files with 4 additions and 4 deletions
|
@ -185,7 +185,7 @@ void BigFraction::reduce()
|
|||
m_denominator = denominator_divide.quotient;
|
||||
}
|
||||
|
||||
ByteString BigFraction::to_byte_string(unsigned rounding_threshold) const
|
||||
String BigFraction::to_string(unsigned rounding_threshold) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
if (m_numerator.is_negative() && m_numerator != "0"_bigint)
|
||||
|
@ -240,7 +240,7 @@ ByteString BigFraction::to_byte_string(unsigned rounding_threshold) const
|
|||
builder.append(fractional_value);
|
||||
}
|
||||
|
||||
return builder.to_byte_string();
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
BigFraction BigFraction::sqrt() const
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
// - m_denominator = 10000
|
||||
BigFraction rounded(unsigned rounding_threshold) const;
|
||||
|
||||
ByteString to_byte_string(unsigned rounding_threshold) const;
|
||||
String to_string(unsigned rounding_threshold) const;
|
||||
double to_double() const;
|
||||
|
||||
Crypto::SignedBigInteger const& numerator() const& { return m_numerator; }
|
||||
|
|
|
@ -23,6 +23,6 @@ TEST_CASE(roundtrip_from_string)
|
|||
for (auto valid_number_string : valid_number_strings) {
|
||||
auto result = TRY_OR_FAIL(Crypto::BigFraction::from_string(valid_number_string));
|
||||
auto precision = valid_number_string.length() - valid_number_string.find('.').value();
|
||||
EXPECT_EQ(result.to_byte_string(precision), valid_number_string);
|
||||
EXPECT_EQ(result.to_string(precision), valid_number_string);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue