This is a list of RELEASED changes for the DeciMojo Package.
Fix a bug for BigUInt
comparison: When there are leading zero words, the comparison returns incorrect results (#97).
Version 0.4.1 of DeciMojo introduces implicit type conversion between built-in integral types and arbitrary-precision types.
Now DeciMojo supports implicit type conversion between built-in integeral types (Int
, UInt
, Int8
, UInt8
, Int16
, UInt16
, Int32
, UInt32
, Int64
, UInt64
, Int128
,UInt128
, Int256
, and UInt256
) and the arbitrary-precision types (BigUInt
, BigInt
, and BigDecimal
). This allows you to use these built-in types directly in arithmetic operations with BigInt
and BigUInt
without explicit conversion. The merged type will always be the most compatible one (PR #89, PR #90).
For example, you can now do the following:
from decimojo.prelude import *
fn main() raises:
var a = BInt(Int256(-1234567890))
var b = BigUInt(31415926)
var c = BDec("3.14159265358979323")
print("a =", a)
print("b =", b)
print("c =", c)
print(a * b) # Merged to BInt
print(a + c) # Merged to BDec
print(b + c) # Merged to BDec
print(a * Int(-128)) # Merged to BInt
print(b * UInt(8)) # Merged to BUInt
print(c * Int256(987654321123456789)) # Merged to BDec
var lst = [a, b, c, UInt8(255), Int64(22222), UInt256(1234567890)]
# The list is of the type `List[BigDecimal]`
for i in lst:
print(i, end=", ")
Running the code will give your the following results:
a = -1234567890
b = 31415926
c = 3.14159265358979323
-38785093474216140
-1234567886.85840734641020677
31415929.14159265358979323
158024689920
251327408
3102807559527666386.46423202534973847
-1234567890, 31415926, 3.14159265358979323, 255, 22222, 1234567890,
Optimize the case when you increase the value of a BigInt
object in-place by 1, i.e., i += 1
. This allows you to iterate faster (PR #89). For example, we can compute the time taken to iterate from 0
to 1_000_000
using BigInt
and compare it with the built-in Int
type:
from decimojo.prelude import *
fn main() raises:
i = BigInt(0)
end = BigInt(1_000_000)
while i < end:
print(i)
i += 1
scenario | Time taken |
---|---|
v0.4.0 BigInt |
1.102s |
v0.4.1 BigInt |
0.912s |
Built-in Int |
0.893s |
Fix a bug in BigDecimal
where it cannot create a correct value from a integral scalar, e.g., BDec(UInt16(0))
returns an unitialized BigDecimal
object (PR #89).
Update the tests
module and refactor the test files for BigUInt
(PR #88).
DeciMojo v0.4.0 updates the codebase to Mojo v25.4. This release enables you to use DeciMojo with the latest Mojo features.
DeciMojo v0.3.1 updates the codebase to Mojo v25.3 and replaces the magic
package manager with pixi
. This release enables you to use DeciMojo with the latest Mojo features and the new package manager.
DeciMojo v0.3.0 introduces the arbitrary-precision BigDecimal
type with comprehensive arithmetic operations, comparisons, and mathematical functions (sqrt
, root
, log
, exp
, power
). A new tomlmojo
package supports test refactoring. Improvements include refined BigUInt
constructors, enhanced scale_up_by_power_of_10()
functionality, and a critical multiplication bug fix.
BigDecimal
type with unlimited precision arithmetic.
BigDecimal
: addition, subtraction, multiplication, division, and modulo.BigDecimal
: less than, greater than, equal to, and not equal to.BigDecimal
.BigDecimal
: sqrt
, nroot
, log
, exp
, and power
functions.tomlmojo
to refactor tests (PR #63).BigUInt
(PR #64).BigUInt.scale_up_by_power_of_10()
(PR #72).BigUInt
multiplication where the calcualtion of carry is mistakenly skipped if a word of x2 is zero (PR #70).Version 0.2.0 marks a significant expansion of DeciMojo with the introduction of BigInt
and BigUInt
types, providing unlimited precision integer arithmetic to complement the existing fixed-precision Decimal
type. Core arithmetic functions for the Decimal
type have been completely rewritten using Mojo 25.2’s UInt128
, delivering substantial performance improvements. This release also extends mathematical capabilities with advanced operations including logarithms, exponentials, square roots, and n-th roots for the Decimal
type. The codebase has been reorganized into a more modular structure, enhancing maintainability and extensibility. With comprehensive test coverage, improved documentation in multiple languages, and optimized memory management, v0.2.0 represents a major advancement in both functionality and performance for numerical computing in Mojo.
BigInt
and BigUInt
implementation with unlimited precision integer arithmetic.BigInt
and BigUInt
: addition, subtraction, multiplication, division, modulo and power operations.BigInt
with proper handling of negative values.BigInt
and BigUInt
.Decimal
: square root and n-th root.Decimal
: natural logarithm, base-10 logarithm, and logarithm with arbitrary base.Decimal
.Decimal
type using UInt128
introduced in Mojo 25.2. This significantly improves the performance of Decimal
operations.Decimal
comparison operators for better handling of edge cases.Decimal
for better precision handling.Decimal
.BigInt
and BigUInt
with over 200 test cases covering all operations and edge cases.Decimal
and BigInt
.