Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-foundation

Source of release 0.6.1

0.6.1 / src / ak / fixed_point_1.lucb

#==============================================================================================
#
#   fixed_point_1 - FixedPoint<precision, Underlying>: precisions and the i32 instantiation
#
#   DESCRIPTION:
#       Port of AK/FixedPoint.h (lines 1-482). luce-base has no value generics and its
#       generics cannot compute on a type parameter, so FixedPoint<precision, Underlying> is
#       `FixedPoint[Underlying, P]`: the underlying integer is spelled out per instantiation
#       (a `_i32`, `_u32`, `_u64` or `_u8` suffix, fixed_point_1 to fixed_point_4; the casts
#       between them are fixed_point_5) and the
#       precision is a type argument `P`, a one-byte marker implementing FixedPointPrecision
#       (`FixedPointPrecision16`). `FixedPoint<16>` is `FixedPoint[i32, FixedPointPrecision16]`.
#       The `Integral I` operands are i64 and converted as C++ converts an int argument; the
#       `FloatingPoint F` conversions exist for f32 and f64; operator* and operator/ on u64 use
#       U128 where the donor uses __int128. The Formatter is AK/Format's (r03) and the
#       FloatingPoint comparisons have no stub, so neither is here.
#
#==============================================================================================

# mark: Precisions ==============================================================================

## The `size_t precision` template argument of FixedPoint, as a type: a marker whose
## precision() answers it.
pub interface FixedPointPrecision:
    func precision() -> usize

## FixedPoint precision 4.
pub struct FixedPointPrecision4: FixedPointPrecision:
    var empty_: u8

    func precision() -> usize: return 4

## FixedPoint precision 6.
pub struct FixedPointPrecision6: FixedPointPrecision:
    var empty_: u8

    func precision() -> usize: return 6

## FixedPoint precision 8.
pub struct FixedPointPrecision8: FixedPointPrecision:
    var empty_: u8

    func precision() -> usize: return 8

## FixedPoint precision 16 (the default: FixedPoint<16> is s15.16 with an i32).
pub struct FixedPointPrecision16: FixedPointPrecision:
    var empty_: u8

    func precision() -> usize: return 16

## FixedPoint precision 24.
pub struct FixedPointPrecision24: FixedPointPrecision:
    var empty_: u8

    func precision() -> usize: return 24

## FixedPoint precision 32.
pub struct FixedPointPrecision32: FixedPointPrecision:
    var empty_: u8

    func precision() -> usize: return 32

# The precision a marker type stands for.
func fixed_point_precision[P: FixedPointPrecision]() -> usize:
    var marker: P = ---
    return marker.precision()

# mark: FixedPoint<precision, i32> ==============================================================

# radix_mask for i32: the fraction bits.
func fixed_point_radix_mask_i32(precision: usize) -> i32:
    return ((i32)1 << (i32)precision) -% 1

## Ported from AK/FixedPoint.h:41 AK::FixedPoint::FixedPoint(Integral), for i32: `value` in the
## integer part.
pub func fixed_point_fixed_point_precision_underlying_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, value: i64):
    let precision = fixed_point_precision[P]()
    this.m_value = (i32)value << (i32)precision

## Ported from AK/FixedPoint.h:46 AK::FixedPoint::FixedPoint(FloatingPoint), for i32 and f64:
## rounded to nearest, ties to even.
pub func fixed_point_construct_f64_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, value: f64):
    let precision = fixed_point_precision[P]()
    this.m_value = rounding_round_to_f64_i32(value * (f64)((i32)1 << (i32)precision))

## Ported from AK/FixedPoint.h:46 AK::FixedPoint::FixedPoint(FloatingPoint), for i32 and f32.
pub func fixed_point_construct_f32_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, value: f32):
    let precision = fixed_point_precision[P]()
    this.m_value = rounding_round_to_f32_i32(value * (f32)((i32)1 << (i32)precision))

## Ported from AK/FixedPoint.h:59 AK::FixedPoint::operator F, for i32 and f64.
pub func fixed_point_to_f64_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> f64:
    let precision = fixed_point_precision[P]()
    return (f64)this.m_value * pow_f64(0.5, (f64)precision)

## Ported from AK/FixedPoint.h:59 AK::FixedPoint::operator F, for i32 and f32.
pub func fixed_point_to_f32_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> f32:
    let precision = fixed_point_precision[P]()
    return (f32)this.m_value * pow_f32(0.5, (f32)precision)

## Ported from AK/FixedPoint.h:65 AK::FixedPoint::operator I, for i32: the truncated integer part.
pub func fixed_point_to_integer_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> i32:
    let precision = fixed_point_precision[P]()
    let truncated = fixed_point_trunc_i32(this)
    return truncated.m_value >> (i32)precision

## Ported from AK/FixedPoint.h:70 AK::FixedPoint::create_raw, for i32.
pub func fixed_point_create_raw_i32[P: FixedPointPrecision](value: i32) -> FixedPoint[i32, P]:
    return FixedPoint[i32, P](m_value = value)

## Ported from AK/FixedPoint.h:77 AK::FixedPoint::raw, for i32.
pub func fixed_point_raw_const_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> i32:
    return this.m_value

## Ported from AK/FixedPoint.h:81 AK::FixedPoint::raw, for i32.
pub func fixed_point_raw_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*) -> i32*:
    return &this.m_value

## Ported from AK/FixedPoint.h:86 AK::FixedPoint::fract, for i32.
pub func fixed_point_fract_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> FixedPoint[i32, P]:
    let precision = fixed_point_precision[P]()
    return fixed_point_create_raw_i32[P](this.m_value & fixed_point_radix_mask_i32(precision))

## Ported from AK/FixedPoint.h:91 AK::FixedPoint::clamp, for i32.
pub func fixed_point_clamp_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, minimum: FixedPoint[i32, P], maximum: FixedPoint[i32, P]) -> FixedPoint[i32, P]:
    if fixed_point_lt_fixed_point_i32(this, minimum):
        return minimum
    if fixed_point_gt_fixed_point_i32(this, maximum):
        return maximum
    return *this

## Ported from AK/FixedPoint.h:100 AK::FixedPoint::rint, for i32.
pub func fixed_point_rint_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> FixedPoint[i32, P]:
    let precision = fixed_point_precision[P]()
    let radix_mask = fixed_point_radix_mask_i32(precision)
    # Note: Round fair, break tie to even
    var value = this.m_value >> (i32)precision

    # Note: For negative numbers the ordering are reversed,
    #       and they were already decremented by the shift, so we need to
    #       add 1 when we see a fract values behind the `.5`s place set,
    #       because that means they are smaller than .5
    # fract(m_value) >= .5?
    if (this.m_value & ((i32)1 << (i32)(precision - 1))) != 0:
        # fract(m_value) > .5?
        if (this.m_value & (radix_mask >> 1)) != 0:
            # yes: round "up";
            value = value + 1
        else:
            #  no: round to even;
            value = value + (value & 1)
    var result: FixedPoint[i32, P] = ---
    fixed_point_fixed_point_precision_underlying_i32(&result, (i64)value)
    return result

## Ported from AK/FixedPoint.h:122 AK::FixedPoint::floor, for i32.
pub func fixed_point_floor_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> FixedPoint[i32, P]:
    let precision = fixed_point_precision[P]()
    return fixed_point_create_raw_i32[P](this.m_value & ~fixed_point_radix_mask_i32(precision))

## Ported from AK/FixedPoint.h:126 AK::FixedPoint::ceil, for i32.
pub func fixed_point_ceil_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> FixedPoint[i32, P]:
    let precision = fixed_point_precision[P]()
    let radix_mask = fixed_point_radix_mask_i32(precision)
    let one: i32 = (i32)1 << (i32)precision
    return fixed_point_create_raw_i32[P]((this.m_value & ~radix_mask) + (one if (this.m_value & radix_mask) != 0 else 0))

## Ported from AK/FixedPoint.h:131 AK::FixedPoint::trunc, for i32.
pub func fixed_point_trunc_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> FixedPoint[i32, P]:
    let precision = fixed_point_precision[P]()
    let radix_mask = fixed_point_radix_mask_i32(precision)
    let one: i32 = (i32)1 << (i32)precision
    var adjustment: i32 = 0
    if (this.m_value & radix_mask) != 0:
        adjustment = 0 if this.m_value > 0 else one
    return fixed_point_create_raw_i32[P]((this.m_value & ~radix_mask) + adjustment)

## Ported from AK/FixedPoint.h:139 AK::FixedPoint::lrint, for i32.
pub func fixed_point_lrint_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> i32:
    let precision = fixed_point_precision[P]()
    let rounded = fixed_point_rint_i32(this)
    return rounded.m_value >> (i32)precision

## Ported from AK/FixedPoint.h:140 AK::FixedPoint::lfloor, for i32.
pub func fixed_point_lfloor_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> i32:
    let precision = fixed_point_precision[P]()
    return this.m_value >> (i32)precision

## Ported from AK/FixedPoint.h:141 AK::FixedPoint::lceil, for i32.
pub func fixed_point_lceil_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> i32:
    let precision = fixed_point_precision[P]()
    let radix_mask = fixed_point_radix_mask_i32(precision)
    return (this.m_value >> (i32)precision) + (1 if (this.m_value & radix_mask) != 0 else 0)

## Ported from AK/FixedPoint.h:146 AK::FixedPoint::ltrunc, for i32.
pub func fixed_point_ltrunc_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> i32:
    let precision = fixed_point_precision[P]()
    let radix_mask = fixed_point_radix_mask_i32(precision)
    var adjustment: i32 = 0
    if (this.m_value & radix_mask) != 0:
        adjustment = 0 if this.m_value > 0 else 1
    return (this.m_value >> (i32)precision) + adjustment

## Ported from AK/FixedPoint.h:155 AK::FixedPoint::log2, for i32.
# http://www.claysturner.com/dsp/BinaryLogarithm.pdf
pub func fixed_point_log2_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> FixedPoint[i32, P]:
    let precision = fixed_point_precision[P]()
    # 0.5
    var b = fixed_point_create_raw_i32[P]((i32)1 << (i32)(precision - 1))
    var y: FixedPoint[i32, P] = ---
    fixed_point_fixed_point_precision_underlying_i32(&y, 0)
    var x = *this

    # FIXME: There's no negative infinity.
    if x.m_value <= 0:
        return fixed_point_create_raw_i32[P](i32_min)

    if fixed_point_ne_i_i32(&x, 1):
        let shift_amount = (i32)log2_i32(x.m_value) - (i32)precision
        if shift_amount > 0:
            _ = fixed_point_shr_assign_i32(&x, (i64)shift_amount)
        else:
            _ = fixed_point_shl_assign_i32(&x, (i64)-shift_amount)
        _ = fixed_point_add_assign_i_i32(&y, (i64)shift_amount)

    for _i in 0..<precision:
        _ = fixed_point_mul_assign_fixed_point_i32(&x, x)
        if fixed_point_ge_i_i32(&x, 2):
            _ = fixed_point_shr_assign_i32(&x, 1)
            _ = fixed_point_add_assign_fixed_point_i32(&y, b)
        _ = fixed_point_shr_assign_i32(&b, 1)

    return y

## Ported from AK/FixedPoint.h:187 AK::FixedPoint::signbit, for i32.
pub func fixed_point_signbit_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> bool:
    return (this.m_value >> (32 - 1)) != 0

## Ported from AK/FixedPoint.h:193 AK::FixedPoint::operator- (negation), for i32.
pub func fixed_point_neg_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*) -> FixedPoint[i32, P]:
    return fixed_point_create_raw_i32[P](-this.m_value)

## Ported from AK/FixedPoint.h:199 AK::FixedPoint::operator+(FixedPoint), for i32.
pub func fixed_point_add_fixed_point_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> FixedPoint[i32, P]:
    return fixed_point_create_raw_i32[P](this.m_value + other.m_value)

## Ported from AK/FixedPoint.h:203 AK::FixedPoint::operator-(FixedPoint), for i32.
pub func fixed_point_sub_fixed_point_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> FixedPoint[i32, P]:
    return fixed_point_create_raw_i32[P](this.m_value - other.m_value)

## Ported from AK/FixedPoint.h:207 AK::FixedPoint::operator*(FixedPoint), for i32 (the
## __SIZEOF_INT128__ branch: MulRes is i64).
pub func fixed_point_mul_fixed_point_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> FixedPoint[i32, P]:
    let precision = fixed_point_precision[P]()
    # FIXME: Figure out a nicer way to use more narrow types and avoid __int128
    var value = (i64)this.m_value
    value = value *% (i64)other.m_value

    var ret = fixed_point_create_raw_i32[P]((i32)(value >> (i64)precision))
    # Rounding:
    # If last bit cut off is 1:
    if (value & (i64)((i32)1 << (i32)(precision - 1))) != 0:
        # If the bit after is 1 as well
        if (value & (i64)(fixed_point_radix_mask_i32(precision) >> 1)) != 0:
            # We round away from 0
            ret.m_value = ret.m_value + 1
        else:
            # Otherwise we round to the next even value
            # Which means we add the least significant bit of the raw return value
            ret.m_value = ret.m_value + (ret.m_value & 1)
    return ret

## Ported from AK/FixedPoint.h:240 AK::FixedPoint::operator/(FixedPoint), for i32 (DivRes is i64).
pub func fixed_point_div_fixed_point_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> FixedPoint[i32, P]:
    let precision = fixed_point_precision[P]()
    # FIXME: Figure out a nicer way to use more narrow types and avoid __int128
    var value = (i64)this.m_value
    value = value << (i64)precision
    value = value // (i64)other.m_value

    return fixed_point_create_raw_i32[P]((i32)value)

## Ported from AK/FixedPoint.h:273 AK::FixedPoint::operator+(Integral), for i32.
pub func fixed_point_add_i_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]:
    let precision = fixed_point_precision[P]()
    return fixed_point_create_raw_i32[P](this.m_value + ((i32)other << (i32)precision))

## Ported from AK/FixedPoint.h:278 AK::FixedPoint::operator-(Integral), for i32.
pub func fixed_point_sub_i_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]:
    let precision = fixed_point_precision[P]()
    return fixed_point_create_raw_i32[P](this.m_value - ((i32)other << (i32)precision))

## Ported from AK/FixedPoint.h:283 AK::FixedPoint::operator*(Integral), for i32.
pub func fixed_point_mul_i_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]:
    return fixed_point_create_raw_i32[P](this.m_value * (i32)other)

## Ported from AK/FixedPoint.h:288 AK::FixedPoint::operator/(Integral), for i32.
pub func fixed_point_div_i_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]:
    return fixed_point_create_raw_i32[P](this.m_value // (i32)other)

## Ported from AK/FixedPoint.h:293 AK::FixedPoint::operator>>(Integral), for i32.
pub func fixed_point_shr_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]:
    return fixed_point_create_raw_i32[P](this.m_value >> (i32)other)

## Ported from AK/FixedPoint.h:298 AK::FixedPoint::operator<<(Integral), for i32.
pub func fixed_point_shl_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]:
    return fixed_point_create_raw_i32[P](this.m_value << (i32)other)

## Ported from AK/FixedPoint.h:303 AK::FixedPoint::operator+=(FixedPoint), for i32.
pub func fixed_point_add_assign_fixed_point_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> FixedPoint[i32, P]*:
    this.m_value = this.m_value + other.m_value
    return this

## Ported from AK/FixedPoint.h:308 AK::FixedPoint::operator-=(FixedPoint), for i32.
pub func fixed_point_sub_assign_fixed_point_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> FixedPoint[i32, P]*:
    this.m_value = this.m_value - other.m_value
    return this

## Ported from AK/FixedPoint.h:313 AK::FixedPoint::operator*=(FixedPoint), for i32.
pub func fixed_point_mul_assign_fixed_point_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> FixedPoint[i32, P]*:
    *this = fixed_point_mul_fixed_point_i32(this, other)
    return this

## Ported from AK/FixedPoint.h:318 AK::FixedPoint::operator/=(FixedPoint), for i32.
pub func fixed_point_div_assign_fixed_point_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> FixedPoint[i32, P]*:
    *this = fixed_point_div_fixed_point_i32(this, other)
    return this

## Ported from AK/FixedPoint.h:325 AK::FixedPoint::operator+=(Integral), for i32.
pub func fixed_point_add_assign_i_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]*:
    *this = fixed_point_add_i_i32(this, other)
    return this

## Ported from AK/FixedPoint.h:331 AK::FixedPoint::operator-=(Integral), for i32.
pub func fixed_point_sub_assign_i_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]*:
    *this = fixed_point_sub_i_i32(this, other)
    return this

## Ported from AK/FixedPoint.h:337 AK::FixedPoint::operator*=(Integral), for i32.
pub func fixed_point_mul_assign_i_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]*:
    *this = fixed_point_mul_i_i32(this, other)
    return this

## Ported from AK/FixedPoint.h:343 AK::FixedPoint::operator/=(Integral), for i32.
pub func fixed_point_div_assign_i_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]*:
    *this = fixed_point_div_i_i32(this, other)
    return this

## Ported from AK/FixedPoint.h:349 AK::FixedPoint::operator>>=(Integral), for i32.
pub func fixed_point_shr_assign_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]*:
    *this = fixed_point_shr_i32(this, other)
    return this

## Ported from AK/FixedPoint.h:355 AK::FixedPoint::operator<<=(Integral), for i32.
pub func fixed_point_shl_assign_i32[P: FixedPointPrecision](this: FixedPoint[i32, P]*, other: i64) -> FixedPoint[i32, P]*:
    *this = fixed_point_shl_i32(this, other)
    return this

## Ported from AK/FixedPoint.h:361 AK::FixedPoint::operator==(FixedPoint), for i32.
pub func fixed_point_eq_fixed_point_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> bool:
    return this.m_value == other.m_value

## Ported from AK/FixedPoint.h:362 AK::FixedPoint::operator!=(FixedPoint), for i32.
pub func fixed_point_ne_fixed_point_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> bool:
    return this.m_value != other.m_value

## Ported from AK/FixedPoint.h:363 AK::FixedPoint::operator>(FixedPoint), for i32.
pub func fixed_point_gt_fixed_point_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> bool:
    return this.m_value > other.m_value

## Ported from AK/FixedPoint.h:364 AK::FixedPoint::operator>=(FixedPoint), for i32.
pub func fixed_point_ge_fixed_point_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> bool:
    return this.m_value >= other.m_value

## Ported from AK/FixedPoint.h:365 AK::FixedPoint::operator<(FixedPoint), for i32.
pub func fixed_point_lt_fixed_point_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> bool:
    return this.m_value < other.m_value

## Ported from AK/FixedPoint.h:366 AK::FixedPoint::operator<=(FixedPoint), for i32.
pub func fixed_point_le_fixed_point_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: FixedPoint[i32, P]) -> bool:
    return this.m_value <= other.m_value

## Ported from AK/FixedPoint.h:370 AK::FixedPoint::operator==(Integral), for i32.
# FIXME: There are probably better ways to do these
pub func fixed_point_eq_i_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> bool:
    let precision = fixed_point_precision[P]()
    return (i32)(this.m_value >> (i32)precision) == (i32)other and (this.m_value & fixed_point_radix_mask_i32(precision)) == 0

## Ported from AK/FixedPoint.h:375 AK::FixedPoint::operator!=(Integral), for i32.
pub func fixed_point_ne_i_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> bool:
    let precision = fixed_point_precision[P]()
    return (i32)(this.m_value >> (i32)precision) != (i32)other or (this.m_value & fixed_point_radix_mask_i32(precision)) != 0

## Ported from AK/FixedPoint.h:380 AK::FixedPoint::operator>(Integral), for i32.
pub func fixed_point_gt_i_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> bool:
    return not fixed_point_le_i_i32(this, other)

## Ported from AK/FixedPoint.h:385 AK::FixedPoint::operator>=(Integral), for i32.
pub func fixed_point_ge_i_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> bool:
    return not fixed_point_lt_i_i32(this, other)

## Ported from AK/FixedPoint.h:390 AK::FixedPoint::operator<(Integral), for i32.
pub func fixed_point_lt_i_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> bool:
    let precision = fixed_point_precision[P]()
    return (i32)(this.m_value >> (i32)precision) < (i32)other or this.m_value < ((i32)other << (i32)precision)

## Ported from AK/FixedPoint.h:395 AK::FixedPoint::operator<=(Integral), for i32.
pub func fixed_point_le_i_i32[P: FixedPointPrecision](this: const FixedPoint[i32, P]*, other: i64) -> bool:
    return fixed_point_lt_i_i32(this, other) or fixed_point_eq_i_i32(this, other)