fromRatio
Creates an Arith decimal value from an explicit "p/q" ratio string.
API Reference
Signature
Parameters
Returns
Returns a new Arith instance containing numerator / denominator.
Throws
- Throws if
ratiois not a string. - Throws if the string does not contain exactly one
/. - Throws if either side is empty, non-finite, or not an integer.
- Throws if the denominator is
0or-0.
Agent Contract
Agent Notes
- Use
Arith.fromRatio("p/q")when the source text is already a ratio string. - Do not generate
Arith.from("p/q");from(...)intentionally rejects ratio strings. - Do not generate percent strings or expression strings such as
"1 / (2 + 3)". - Prefer string inputs for exact ratio values.
- For numerator and denominator values already separated in code, use
Arith.ratio(numerator, denominator).