1010#include < AK/Math.h>
1111#include < AK/StringBuilder.h>
1212#include < LibCrypto/BigInt/UnsignedBigInteger.h>
13- #include < LibCrypto/NumberTheory/ModularFunctions.h>
1413
1514namespace Crypto {
1615
@@ -36,12 +35,11 @@ ErrorOr<BigFraction> BigFraction::from_string(StringView sv)
3635
3736 auto integer_part = TRY (SignedBigInteger::from_base (10 , integer_part_view));
3837 auto fractional_part = TRY (SignedBigInteger::from_base (10 , fraction_part_view));
39- auto fraction_length = UnsignedBigInteger (static_cast <u64 >(fraction_part_view.length ()));
4038
4139 if (!sv.is_empty () && sv[0 ] == ' -' )
4240 fractional_part.negate ();
4341
44- return BigFraction (move (integer_part)) + BigFraction (move (fractional_part), NumberTheory::Power ( " 10" _bigint, move (fraction_length )));
42+ return BigFraction (move (integer_part)) + BigFraction (move (fractional_part), " 10" _bigint. pow (fraction_part_view. length ( )));
4543}
4644
4745BigFraction BigFraction::operator +(BigFraction const & rhs) const
@@ -129,7 +127,7 @@ BigFraction::BigFraction(double d)
129127 d -= digit * AK::pow (10.0 , (double )current_pow);
130128 if (current_pow < 0 ) {
131129 ++decimal_places;
132- m_denominator.set_to (NumberTheory::Power ( " 10" _bigint, UnsignedBigInteger { decimal_places } ));
130+ m_denominator.set_to (" 10" _bigint. pow ( decimal_places));
133131 }
134132 current_pow -= 1 ;
135133 }
@@ -205,7 +203,7 @@ BigFraction BigFraction::rounded(unsigned rounding_threshold) const
205203 auto res = m_numerator.divided_by (m_denominator);
206204 BigFraction result { move (res.quotient ) };
207205
208- auto const needed_power = NumberTheory::Power ( " 10" _bigint, UnsignedBigInteger { rounding_threshold } );
206+ auto const needed_power = " 10" _bigint. pow ( rounding_threshold);
209207 // We get one more digit to do proper rounding
210208 auto const fractional_value = res.remainder .multiplied_by (needed_power.multiplied_by (" 10" _bigint)).divided_by (m_denominator).quotient ;
211209
@@ -221,7 +219,7 @@ BigFraction BigFraction::rounded(unsigned rounding_threshold) const
221219
222220void BigFraction::reduce ()
223221{
224- auto const gcd = NumberTheory::GCD ( m_numerator.unsigned_value (), m_denominator);
222+ auto const gcd = m_numerator.unsigned_value (). gcd ( m_denominator);
225223
226224 if (gcd == 1 )
227225 return ;
0 commit comments