52 lines
1.8 KiB
Markdown
52 lines
1.8 KiB
Markdown
---
|
|
epic: 1
|
|
story: 1.4
|
|
title: "Arbitrary Precision Arithmetic"
|
|
status: draft
|
|
---
|
|
|
|
## Epic 1 — Core Calculation Engine (Rust Crate)
|
|
**Goal:** Build `calcpad-engine` as a standalone Rust crate that powers all platforms. This is the foundation.
|
|
|
|
### Story 1.4: Arbitrary Precision Arithmetic
|
|
|
|
As a CalcPad user,
|
|
I want calculations precise to at least 30 significant digits with no floating-point drift,
|
|
So that financial calculations and large factorials produce exact, trustworthy results.
|
|
|
|
**Acceptance Criteria:**
|
|
|
|
**Given** the expression `0.1 + 0.2`
|
|
**When** the engine evaluates it
|
|
**Then** the result is exactly `0.3`
|
|
**And** there is no floating-point representation error
|
|
|
|
**Given** the expression `100!`
|
|
**When** the engine evaluates it
|
|
**Then** it returns the exact integer value (158 digits)
|
|
**And** no precision is lost
|
|
|
|
**Given** the expression `1 / 3`
|
|
**When** the engine evaluates it
|
|
**Then** it returns a result precise to at least 30 significant digits
|
|
**And** the display is appropriately rounded for the user
|
|
|
|
**Given** the expression `0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1`
|
|
**When** the engine evaluates it
|
|
**Then** the result is exactly `1.0`
|
|
|
|
**Given** a financial expression such as `$1000000.01 * 365`
|
|
**When** the engine evaluates it
|
|
**Then** the result preserves cents-level precision with no drift
|
|
**And** the result is `$365000003.65`
|
|
|
|
**Given** the engine is compiled to WASM
|
|
**When** arbitrary precision operations execute
|
|
**Then** the `dashu` crate functions correctly in the WASM target
|
|
**And** no platform-specific numeric behavior differs from native
|
|
|
|
**Given** an expression involving very large numbers such as `2^1000`
|
|
**When** the engine evaluates it
|
|
**Then** the exact integer result is returned
|
|
**And** the engine does not overflow or panic
|