@internal
This page tracks the 0.7.1 implementation helper API, not a stable application contract.
@internal is an implementation-facing package. Its functions are documented here for maintainers and advanced contributors, not as a stable public API promise.
BigInt Helpers
fn bigint_zero() -> BigIntReturns0as aBigInt.fn bigint_one() -> BigIntReturns1as aBigInt.fn abs_bigint(x : BigInt) -> BigIntReturns the absolute value ofx.fn sign_of_bigint(x : BigInt) -> SignConverts aBigIntsign intoSign::Negative,Sign::Zero, orSign::Positive.
Power Helpers
fn pow2(n : Int) -> BigIntReturns2^n. Rejects negativen.fn pow5(n : Int) -> BigIntReturns5^n. Rejects negativen.fn pow10(n : Int) -> BigIntReturns10^n. Rejects negativen.fn digits10(x : BigInt) -> IntReturns the decimal digit count of the absolute value ofx.
Normalization Helpers
fn remove_factor2(sig : BigInt, exp : Int) -> (BigInt, Int)Removes all factors of2fromsigand compensates them into the returned exponent.fn remove_factor10(coeff : BigInt, exp : Int) -> (BigInt, Int)Removes all factors of10fromcoeffand compensates them into the returned exponent.fn exact_divide_by_power_of_ten(value : BigInt, exponent : Int) -> BigInt?Returns the exact quotient whenvalueis divisible by10^exponent; otherwise returnsNone.fn trim_trailing_decimal_zeros(value : BigInt, exponent : Int, max_drop? : Int) -> (BigInt, Int, Int)Removes at mostmax_droptrailing decimal zeros, adjusts the exponent, and reports the number removed.
Rounding Helpers
fn round_positive_div(numerator : BigInt, denominator : BigInt, negative : Bool, mode : RoundingMode) -> BigIntRounds the positive quotientnumerator / denominatoraccording tomode. Thenegativeflag lets the routine interpret directed rounding correctly for signed values.fn round_shift(magnitude : BigInt, shift : Int, negative : Bool, mode : RoundingMode) -> BigIntRounds a right-shift-by-shiftoperation on a non-negative magnitude.fn compare_abs(a : BigInt, b : BigInt) -> IntCompares absolute values only.
Decimal Parsing Helper
fn split_decimal_string(src : String) -> (Bool, String, Int)?Splits a decimal string into:- sign flag
- digit string without separators
- base-10 exponent adjustment
It accepts plain decimals and scientific notation in the currently implemented parser.
Complete Public Interface
The following snapshot is the complete generated package interface for 0.7.1. Public declarations are authoritative; prose above groups them by behavior.
// Generated using `moon info`, DON'T EDIT IT
package "Luna-Flow/floating/internal"
import {
"Luna-Flow/arithmetic",
"Luna-Flow/floating/def",
"moonbitlang/core/bigint",
}
// Values
pub fn abs_bigint(@bigint.BigInt) -> @bigint.BigInt
pub fn bigint_one() -> @bigint.BigInt
pub fn bigint_zero() -> @bigint.BigInt
pub fn certified_dyadic_div(CertifiedDyadic, CertifiedDyadic, Int) -> Result[CertifiedInterval[CertifiedDyadic], @arithmetic.ArithmeticError]
pub fn certified_dyadic_fraction(@bigint.BigInt, @bigint.BigInt, Int) -> Result[CertifiedInterval[CertifiedDyadic], @arithmetic.ArithmeticError]
pub fn certified_failure(String, @arithmetic.CertificationStage, @arithmetic.CertificationFailureReason, Int, CertifiedRefinementBudget) -> @arithmetic.ArithmeticError
pub fn compare_abs(@bigint.BigInt, @bigint.BigInt) -> Int
pub fn digits10(@bigint.BigInt) -> Int
pub fn exact_divide_by_power_of_ten(@bigint.BigInt, Int) -> @bigint.BigInt?
pub fn pow10(Int) -> @bigint.BigInt
pub fn pow2(Int) -> @bigint.BigInt
pub fn pow5(Int) -> @bigint.BigInt
pub fn remove_factor10(@bigint.BigInt, Int) -> (@bigint.BigInt, Int)
pub fn remove_factor2(@bigint.BigInt, Int) -> (@bigint.BigInt, Int)
pub fn[A, B, E, C] result_lift2(Result[A, E], Result[B, E], (A, B) -> C) -> Result[C, E]
pub fn[A, B, E, C] result_lift2_checked(Result[A, E], Result[B, E], (A, B) -> Result[C, E]) -> Result[C, E]
pub fn round_positive_div(@bigint.BigInt, @bigint.BigInt, Bool, @arithmetic.RoundingMode) -> @bigint.BigInt
pub fn round_shift(@bigint.BigInt, Int, Bool, @arithmetic.RoundingMode) -> @bigint.BigInt
pub fn sign_of_bigint(@bigint.BigInt) -> @def.Sign
pub fn split_decimal_string(String) -> (Bool, String, Int)?
pub fn trim_trailing_decimal_zeros(@bigint.BigInt, Int, max_drop? : Int) -> (@bigint.BigInt, Int, Int)
// Errors
// Types and methods
pub struct CertifiedDyadic {
numerator_ : @bigint.BigInt
scale_ : Int
}
pub fn CertifiedDyadic::add(Self, Self) -> Self
pub fn CertifiedDyadic::compare(Self, Self) -> Int
pub fn CertifiedDyadic::from_int(Int) -> Self
pub fn CertifiedDyadic::mul(Self, Self) -> Self
pub fn CertifiedDyadic::neg(Self) -> Self
pub fn CertifiedDyadic::new(@bigint.BigInt, Int) -> Self
pub fn CertifiedDyadic::numerator(Self) -> @bigint.BigInt
pub fn CertifiedDyadic::round_down(Self, Int) -> Self
pub fn CertifiedDyadic::round_up(Self, Int) -> Self
pub fn CertifiedDyadic::scale(Self) -> Int
pub fn CertifiedDyadic::sub(Self, Self) -> Self
pub struct CertifiedInterval[T] {
lower_ : T
upper_ : T
}
pub fn[T] CertifiedInterval::lower(Self[T]) -> T
pub fn[T] CertifiedInterval::new(T, T, (T, T) -> Int) -> Result[Self[T], @arithmetic.ArithmeticError]
pub fn[T] CertifiedInterval::upper(Self[T]) -> T
pub struct CertifiedRefinementBudget {
work_precision : Int
refinements_ : Int
limit_ : Int
}
pub fn CertifiedRefinementBudget::available(Self) -> Bool
pub fn CertifiedRefinementBudget::new(Int, limit? : Int) -> Self
pub fn CertifiedRefinementBudget::next(Self) -> Self
pub fn CertifiedRefinementBudget::precision(Self) -> Int
pub fn CertifiedRefinementBudget::refinements(Self) -> Int
pub struct ExactRat {
// private fields
} derive(Eq)
pub fn ExactRat::denominator(Self) -> @bigint.BigInt
pub fn ExactRat::new(@bigint.BigInt, @bigint.BigInt) -> Self
pub fn ExactRat::numerator(Self) -> @bigint.BigInt
// Type aliases
// Traits