Crates.io | steel-decimal |
lib.rs | steel-decimal |
version | 1.0.1 |
created_at | 2025-07-08 15:13:04.185144+00 |
updated_at | 2025-07-26 11:11:37.256376+00 |
description | High-precision decimal arithmetic for Steel programming language |
homepage | |
repository | https://gitlab.com/filipriec/steel-decimal |
max_upload_size | |
id | 1742983 |
size | 273,324 |
A Rust library that provides high-precision decimal arithmetic support for the Steel programming language. This crate transforms Steel scripts to use decimal operations and provides function registration utilities for Steel VMs.
rust_decimal
crateAdd this to your Cargo.toml
:
[dependencies]
steel_decimal = "1.0.0"
(+ a b)
→ (decimal-add "a" "b")
(- a b)
→ (decimal-sub "a" "b")
(* a b)
→ (decimal-mul "a" "b")
(/ a b)
→ (decimal-div "a" "b")
(^ base exp)
→ (decimal-pow "base" "exp")
(sqrt x)
→ (decimal-sqrt "x")
(ln x)
→ (decimal-ln "x")
(log10 x)
→ (decimal-log10 "x")
(exp x)
→ (decimal-exp "x")
(sin x)
, (cos x)
, (tan x)
(> a b)
, (< a b)
, (= a b)
, (>= a b)
, (<= a b)
(decimal-percentage amount rate)
(decimal-compound principal rate time)
(set-precision 4)
(get-precision)
(clear-precision)
The crate includes several examples:
cargo run --example basic_usage
cargo run --example arithmetic_only
cargo run --example advanced_math
cargo run --example financial_calculations
cargo run --example precision_control
cargo run --example simple_variables
cargo run --example standalone_engine
cargo run --example comparison_methods
Steel Decimal supports scientific notation in decimal parsing:
let script = "(+ 1.5e2 2.3e-1)"; // 150 + 0.23 = 150.23
let transformed = steel_decimal.transform(script);
Precision settings are thread-local, allowing different threads to use different precision contexts safely.
This project is licensed under either of
at your option.