Skip to content
FloatAllocator

FloatAllocator

Description

Allocator backing the float’s storage.

Parameters

Name Direction Description
value in Float to query.

Usage example (Cross-references)

Usage examples (Cross-references)
        }
    
        temp   = StrInit(FloatAllocator(value));
        parsed = FloatInit(FloatAllocator(value));
    
        temp   = StrInit(FloatAllocator(value));
        parsed = FloatInit(FloatAllocator(value));
    
        if (float_fmt_uses_unsupported_flags(fmt_info)) {
    
        StrDeinit(&temp);
        temp = StrInitFromCstr(start, token_len, FloatAllocator(value));
        if (!FloatTryFromStr(&parsed, StrBegin(&temp))) {
            StrDeinit(&temp);
        {
            u64 places = (u64)(value->exponent - target_exponent);
            Int factor = IntInit(FloatAllocator(value));
            Int scaled = IntInit(FloatAllocator(value));
            u64 places = (u64)(value->exponent - target_exponent);
            Int factor = IntInit(FloatAllocator(value));
            Int scaled = IntInit(FloatAllocator(value));
    
            if (!float_pow10(&factor, places, FloatAllocator(value)) || !int_mul(&scaled, &value->significand, &factor)) {
            Int scaled = IntInit(FloatAllocator(value));
    
            if (!float_pow10(&factor, places, FloatAllocator(value)) || !int_mul(&scaled, &value->significand, &factor)) {
                IntDeinit(&factor);
                IntDeinit(&scaled);
        {
            i64   target_exponent = lhs->exponent < rhs->exponent ? lhs->exponent : rhs->exponent;
            Float lhs_scaled      = FloatInit(FloatAllocator(lhs));
            Float rhs_scaled      = FloatInit(FloatAllocator(rhs));
            i64   target_exponent = lhs->exponent < rhs->exponent ? lhs->exponent : rhs->exponent;
            Float lhs_scaled      = FloatInit(FloatAllocator(lhs));
            Float rhs_scaled      = FloatInit(FloatAllocator(rhs));
    
            if (!FloatTryClone(&lhs_scaled, lhs) || !FloatTryClone(&rhs_scaled, rhs) ||
    
        while (int_mod_u64(&value->significand, 10) == 0) {
            Int quotient = IntInit(FloatAllocator(value));
    
            (void)int_div_u64_rem(&quotient, &value->significand, 10);
    
        ValidateFloat(value);
        clone = FloatInit(FloatAllocator(value));
        (void)FloatTryClone(&clone, value);
        return clone;
    
        ValidateFloat(value);
        *out          = FloatInit(FloatAllocator(value));
        out->negative = value->negative;
        out->exponent = value->exponent;
        if (!IntTryClone(&out->significand, &value->significand)) {
            FloatDeinit(out);
            *out = FloatInit(FloatAllocator(value));
            return false;
        }
    
        if (value->exponent >= 0) {
            Int factor = IntInit(FloatAllocator(value));
    
            if (!IntTryClone(&temp, &value->significand) ||
    
            if (!IntTryClone(&temp, &value->significand) ||
                !float_pow10(&factor, (u64)value->exponent, FloatAllocator(value)) || !int_mul(&temp, &temp, &factor)) {
                IntDeinit(&factor);
                IntDeinit(&temp);
        {
            u64  places = (u64)(-value->exponent);
            Int  factor = IntInit(FloatAllocator(value));
            bool ok     = false;
            bool ok     = false;
    
            if (!float_pow10(&factor, places, FloatAllocator(value))) {
                IntDeinit(&factor);
                return false;
    
        ValidateFloat(out);
        result = FloatInit(FloatAllocator(out));
        digits = StrInit(FloatAllocator(out));
        ValidateFloat(out);
        result = FloatInit(FloatAllocator(out));
        digits = StrInit(FloatAllocator(out));
    
        if (pos < length && (text[pos] == '+' || text[pos] == '-')) {
    
    int float_compare_int_with_error(const Float *lhs, const Int *rhs, bool *error) {
        Float rhs_value = FloatInit(FloatAllocator(lhs));
        int   cmp       = 0;
    
    int float_compare_u64_with_error(const Float *lhs, u64 rhs, bool *error) {
        Float rhs_value = FloatInit(FloatAllocator(lhs));
        int   cmp       = 0;
        }
    
        if (!float_try_from_u64_value(&rhs_value, rhs, FloatAllocator(lhs))) {
            if (error) {
                *error = true;
    
    int float_compare_i64_with_error(const Float *lhs, i64 rhs, bool *error) {
        Float rhs_value = FloatInit(FloatAllocator(lhs));
        int   cmp       = 0;
        }
    
        if (!float_try_from_i64_value(&rhs_value, rhs, FloatAllocator(lhs))) {
            if (error) {
                *error = true;
    
    int float_compare_f32_with_error(const Float *lhs, float rhs, bool *error) {
        Float rhs_value = FloatInit(FloatAllocator(lhs));
        int   cmp       = 0;
        }
    
        if (!float_try_from_f32_value(&rhs_value, rhs, FloatAllocator(lhs))) {
            if (error) {
                *error = true;
    
    int float_compare_f64_with_error(const Float *lhs, double rhs, bool *error) {
        Float rhs_value = FloatInit(FloatAllocator(lhs));
        int   cmp       = 0;
        }
    
        if (!float_try_from_f64_value(&rhs_value, rhs, FloatAllocator(lhs))) {
            if (error) {
                *error = true;
        ValidateFloat(a);
        ValidateFloat(b);
        lhs  = FloatInit(FloatAllocator(a));
        rhs  = FloatInit(FloatAllocator(b));
        temp = FloatInit(FloatAllocator(result));
        ValidateFloat(b);
        lhs  = FloatInit(FloatAllocator(a));
        rhs  = FloatInit(FloatAllocator(b));
        temp = FloatInit(FloatAllocator(result));
        lhs  = FloatInit(FloatAllocator(a));
        rhs  = FloatInit(FloatAllocator(b));
        temp = FloatInit(FloatAllocator(result));
    
        if (!FloatTryClone(&lhs, a) || !FloatTryClone(&rhs, b)) {
    
    bool float_add_int(Float *result, const Float *a, const Int *b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_int_value(&rhs, b)) {
    
    bool float_add_u64(Float *result, const Float *a, u64 b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_u64_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_u64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_add_i64(Float *result, const Float *a, i64 b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_i64_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_i64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_add_f32(Float *result, const Float *a, float b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f32_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f32_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_add_f64(Float *result, const Float *a, double b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f64_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_sub(Float *result, const Float *a, const Float *b) {
        Float rhs = FloatInit(FloatAllocator(b));
    
        ValidateFloat(result);
    
    bool float_sub_int(Float *result, const Float *a, const Int *b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_int_value(&rhs, b)) {
    
    bool float_sub_u64(Float *result, const Float *a, u64 b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_u64_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_u64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_sub_i64(Float *result, const Float *a, i64 b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_i64_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_i64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_sub_f32(Float *result, const Float *a, float b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f32_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f32_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_sub_f64(Float *result, const Float *a, double b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f64_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_mul(Float *result, const Float *a, const Float *b) {
        Float temp = FloatInit(FloatAllocator(result));
    
        ValidateFloat(result);
    
    bool float_mul_int(Float *result, const Float *a, const Int *b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_int_value(&rhs, b)) {
    
    bool float_mul_u64(Float *result, const Float *a, u64 b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_u64_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_u64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_mul_i64(Float *result, const Float *a, i64 b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_i64_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_i64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_mul_f32(Float *result, const Float *a, float b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f32_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f32_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_mul_f64(Float *result, const Float *a, double b) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f64_value(&rhs, b, FloatAllocator(result))) {
        Float rhs = FloatInit(FloatAllocator(result));
    
        if (!float_try_from_f64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_div(Float *result, const Float *a, const Float *b, u64 precision) {
        Float temp   = FloatInit(FloatAllocator(result));
        Int   scale  = IntInit(FloatAllocator(result));
        Int   scaled = IntInit(FloatAllocator(result));
    bool float_div(Float *result, const Float *a, const Float *b, u64 precision) {
        Float temp   = FloatInit(FloatAllocator(result));
        Int   scale  = IntInit(FloatAllocator(result));
        Int   scaled = IntInit(FloatAllocator(result));
        Float temp   = FloatInit(FloatAllocator(result));
        Int   scale  = IntInit(FloatAllocator(result));
        Int   scaled = IntInit(FloatAllocator(result));
    
        ValidateFloat(result);
        }
        if (FloatIsZero(a)) {
            Float zero = FloatInit(FloatAllocator(result));
    
            FloatDeinit(result);
        }
    
        if (!float_pow10(&scale, precision, FloatAllocator(result)) || !int_mul(&scaled, &a->significand, &scale)) {
            IntDeinit(&scale);
            IntDeinit(&scaled);
    
    bool float_div_int(Float *result, const Float *a, const Int *b, u64 precision) {
        Float rhs = FloatInit(FloatAllocator(result));
        bool  ok  = false;
    
    bool float_div_u64(Float *result, const Float *a, u64 b, u64 precision) {
        Float rhs = FloatInit(FloatAllocator(result));
        bool  ok  = false;
        bool  ok  = false;
    
        if (!float_try_from_u64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_div_i64(Float *result, const Float *a, i64 b, u64 precision) {
        Float rhs = FloatInit(FloatAllocator(result));
        bool  ok  = false;
        bool  ok  = false;
    
        if (!float_try_from_i64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_div_f32(Float *result, const Float *a, float b, u64 precision) {
        Float rhs = FloatInit(FloatAllocator(result));
        bool  ok  = false;
        bool  ok  = false;
    
        if (!float_try_from_f32_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
    
    bool float_div_f64(Float *result, const Float *a, double b, u64 precision) {
        Float rhs = FloatInit(FloatAllocator(result));
        bool  ok  = false;
        bool  ok  = false;
    
        if (!float_try_from_f64_value(&rhs, b, FloatAllocator(result))) {
            return false;
        }
        Float clone = FloatClone(&original);
    
        bool result = FloatEQ(&clone, &original) && FloatAllocator(&clone) == FloatAllocator(&original) &&
                      FloatAllocator(&clone)->allocate == FloatAllocator(&original)->allocate &&
                      FloatAllocator(&clone)->remap == FloatAllocator(&original)->remap &&
    
        bool result = FloatEQ(&clone, &original) && FloatAllocator(&clone) == FloatAllocator(&original) &&
                      FloatAllocator(&clone)->allocate == FloatAllocator(&original)->allocate &&
                      FloatAllocator(&clone)->remap == FloatAllocator(&original)->remap &&
                      FloatAllocator(&clone)->deallocate == FloatAllocator(&original)->deallocate &&
        bool result = FloatEQ(&clone, &original) && FloatAllocator(&clone) == FloatAllocator(&original) &&
                      FloatAllocator(&clone)->allocate == FloatAllocator(&original)->allocate &&
                      FloatAllocator(&clone)->remap == FloatAllocator(&original)->remap &&
                      FloatAllocator(&clone)->deallocate == FloatAllocator(&original)->deallocate &&
                      FloatAllocator(&clone)->effort == FloatAllocator(&original)->effort &&
                      FloatAllocator(&clone)->allocate == FloatAllocator(&original)->allocate &&
                      FloatAllocator(&clone)->remap == FloatAllocator(&original)->remap &&
                      FloatAllocator(&clone)->deallocate == FloatAllocator(&original)->deallocate &&
                      FloatAllocator(&clone)->effort == FloatAllocator(&original)->effort &&
                      FloatAllocator(&clone)->retry_limit == FloatAllocator(&original)->retry_limit;
                      FloatAllocator(&clone)->remap == FloatAllocator(&original)->remap &&
                      FloatAllocator(&clone)->deallocate == FloatAllocator(&original)->deallocate &&
                      FloatAllocator(&clone)->effort == FloatAllocator(&original)->effort &&
                      FloatAllocator(&clone)->retry_limit == FloatAllocator(&original)->retry_limit;
                      FloatAllocator(&clone)->deallocate == FloatAllocator(&original)->deallocate &&
                      FloatAllocator(&clone)->effort == FloatAllocator(&original)->effort &&
                      FloatAllocator(&clone)->retry_limit == FloatAllocator(&original)->retry_limit;
    
        FloatDeinit(&original);
    ///
    #define FloatTryToStr(...)                 OVERLOAD(FloatTryToStr, __VA_ARGS__)
    #define FloatTryToStr_2(out, value)        float_try_to_str((out), (value), FloatAllocator((value)))
    #define FloatTryToStr_3(out, value, alloc) float_try_to_str((out), (value), (alloc))
    ///
    #define FloatToStr(...)            OVERLOAD(FloatToStr, __VA_ARGS__)
    #define FloatToStr_1(value)        float_to_str((value), FloatAllocator((value)))
    #define FloatToStr_2(value, alloc) float_to_str((value), (alloc))
Last updated on