Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions benches/bigdecimal/mojo/bench.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _parse_round_param(b: String) raises -> Tuple[Int, RoundingMode]:
raise Error("unknown rounding mode: " + mode_str)


def _cmp_3way(read a: BigDecimal, read b: BigDecimal) raises -> String:
def _cmp_3way(imm a: BigDecimal, imm b: BigDecimal) raises -> String:
"""Stable, cross-language 3-way comparison: returns "-1", "0", or "1"."""
if a < b:
return String("-1")
Expand Down Expand Up @@ -129,8 +129,8 @@ def _emit(v: BigDecimal) raises -> String:

def _result_for(
op: String,
read a: BigDecimal,
read b: BigDecimal,
imm a: BigDecimal,
imm b: BigDecimal,
a_str: String,
b_str: String,
precision: Int,
Expand Down Expand Up @@ -173,8 +173,8 @@ def _result_for(

def _time_kernel(
op: String,
read a: BigDecimal,
read b: BigDecimal,
imm a: BigDecimal,
imm b: BigDecimal,
a_str: String,
b_str: String,
precision: Int,
Expand All @@ -190,7 +190,7 @@ def _time_kernel(
IS the operation under measurement, so those paths keep their
natural shape (parse → BigDecimal, render → String).

Operands `a` / `b` are taken as `read` (borrowed) so no per-iter
Operands `a` / `b` are taken as `imm` (borrowed) so no per-iter
deep copy of the heap-backed BigUInt occurs.
"""
if op == "add":
Expand Down Expand Up @@ -305,9 +305,9 @@ def _bench_case(
# - arithmetic / sqrt / exp / ln: as-is (sqrt/exp/ln are unary)
# - root: b is the root index n
if op == "round" or op == "from_string" or op == "to_string":
b = BigDecimal.from_int(0)
b = BigDecimal.from_integral_scalar(0)
elif bc.b == "":
b = BigDecimal.from_int(0)
b = BigDecimal.from_integral_scalar(0)
else:
b = BigDecimal(bc.b)

Expand Down
14 changes: 7 additions & 7 deletions benches/bigint/mojo/bench.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def _csv_quote(s: String) -> String:

def _result_for(
op: String,
read a: BigInt,
read b: BigInt,
imm a: BigInt,
imm b: BigInt,
a_str: String,
b_int: Int,
) raises -> String:
Expand Down Expand Up @@ -86,8 +86,8 @@ def _result_for(

def _time_kernel(
op: String,
read a: BigInt,
read b: BigInt,
imm a: BigInt,
imm b: BigInt,
a_str: String,
b_int: Int,
) raises:
Expand All @@ -100,7 +100,7 @@ def _time_kernel(
`sign`) to prevent dead-code elimination while keeping the keep cost
negligible versus the op.

Operands `a` / `b` are taken as `read` (borrowed) so no per-iter
Operands `a` / `b` are taken as `imm` (borrowed) so no per-iter
deep copy of the heap-backed word list occurs.
"""
if op == "add":
Expand Down Expand Up @@ -192,10 +192,10 @@ def _bench_case(
var b: BigInt
var b_int: Int = 0
if op == "power" or op == "shift":
b = BigInt.from_int(0)
b = BigInt.from_integral_scalar(0)
b_int = Int(BigInt(bc.b))
elif op == "sqrt" or op == "from_string" or op == "to_string" or bc.b == "":
b = BigInt.from_int(0)
b = BigInt.from_integral_scalar(0)
else:
b = BigInt(bc.b)

Expand Down
4 changes: 3 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

This is a list of changes for the Decimo package (formerly DeciMojo).

## Unreleased
## Unreleased (v0.12.0)

Decimo v0.12.0 retargets the codebase to **Mojo v1.0.0**.

### ⭐️ New

Expand Down
22 changes: 8 additions & 14 deletions docs/user_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,8 @@ Accepts any integral scalar type (`Int8` through `Int256`, `UInt8` through `UInt
| Constructor | Description |
| ---------------------------------- | ------------------------------------- |
| `BInt()` | Zero |
| `BInt(value: Int)` | From `Int` (implicit) |
| `BInt(value: String)` | From decimal string (raises) |
| `BInt(value: Scalar)` | From integral scalar (implicit) |
| `BInt.from_int(value)` | Explicit factory from `Int` |
| `BInt(value: Scalar)` | From any integral scalar (implicit) |
| `BInt.from_integral_scalar(value)` | From any integral scalar type |
| `BInt.from_string(value)` | Explicit factory from string (raises) |
| `BInt.from_bigint10(value)` | Convert from `BigInt10` |
Expand Down Expand Up @@ -554,13 +552,9 @@ var b = Decimal(py=py_dec) # Alternative keyword-only syntax
| Constructor | Description |
| ------------------------------------- | ------------------------------- |
| `Decimal()` | Zero |
| `Decimal(value: Int)` | From `Int` (implicit) |
| `Decimal(value: UInt)` | From `UInt` (implicit) |
| `Decimal(value: String)` | From string (raises) |
| `Decimal(value: Scalar)` | From integral scalar (implicit) |
| `Decimal(value: Scalar)` | From any integral scalar (impl) |
| `Decimal(py=py_obj)` | From Python `Decimal` (raises) |
| `Decimal.from_int(value)` | Explicit factory from `Int` |
| `Decimal.from_uint(value)` | Explicit factory from `UInt` |
| `Decimal.from_integral_scalar(value)` | From any integral scalar type |
| `Decimal.from_float(value)` | From floating-point (raises) |
| `Decimal.from_string(value)` | Explicit factory from string |
Expand Down Expand Up @@ -1037,12 +1031,12 @@ print(Decimal("2.000").to_chinese()) # 二点零零零
The character tables are supplied by `ChineseNumeralStyle`, which ships with
four presets:

| Preset | Digits | Units | 10^4 / 10^8 | Point | Example for `1050` |
| ------------------------- | ------ | -------- | ----------- | ----- | ------------------ |
| `simplified()` (default) | 一二三 | 十百千 | 万 / 亿 | 点 | `一千零五十` |
| `simplified_financial()` | 壹贰叁 | 拾佰仟 | 万 / 亿 | 点 | `壹仟零伍拾` |
| `traditional()` | 一二三 | 十百千 | 萬 / 億 | 點 | `一千零五十` |
| `traditional_financial()` | 壹貳參 | 拾佰仟 | 萬 / 億 | 點 | `壹仟零伍拾` |
| Preset | Digits | Units | 10^4 / 10^8 | Point | Example for `1050` |
| ------------------------- | ------ | ------ | ----------- | ----- | ------------------ |
| `simplified()` (default) | 一二三 | 十百千 | 万 / 亿 | 点 | `一千零五十` |
| `simplified_financial()` | 壹贰叁 | 拾佰仟 | 万 / 亿 | 点 | `壹仟零伍拾` |
| `traditional()` | 一二三 | 十百千 | 萬 / 億 | 點 | `一千零五十` |
| `traditional_financial()` | 壹貳參 | 拾佰仟 | 萬 / 億 | 點 | `壹仟零伍拾` |

```mojo
from decimo import ChineseNumeralStyle
Expand Down
Loading
Loading