Expand description
Mathematical utilities translated faithfully from the legacy calculator
application suite (old/calculator), including Calculator 4.0, assistance/
error solvers, the 6r2 unique random number generator, and the R.P.S.
sidecar game.
Re-exports§
Structs§
- Prime
Verification Result - Structure holding the result of a prime number and factor verification test.
Enums§
- RpsChoice
- Choice options in Rock-Paper-Scissors.
- RpsOutcome
- Outcome of a Rock-Paper-Scissors game round.
- Square
Root Result - Result of a square root evaluation, representing real or imaginary output.
Constants§
- RANDOM_
SCALES - Standard scale multipliers for random table generation.
Functions§
- add
- Performs addition of two floating-point numbers.
- celsius_
to_ fahrenheit - Converts temperature from Celsius to Fahrenheit.
- circle_
area - Calculates the area of a circle given its radius ($\pi \cdot r^2$).
- divide
- Performs floating-point division of two numbers. Returns an error if the divisor is zero.
- evaluate_
basic_ op - Evaluates a basic arithmetic operation given an operator string.
- evaluate_
expression - Evaluates a math expression string with standard operator precedence.
- fahrenheit_
to_ celsius - Converts temperature from Fahrenheit to Celsius.
- format_
modulo_ result - Formats modulo quotient and remainder into legacy output string (
"Q r R"). FIXME: In original version, if n2 is 0 it looks like it returns “{ }” as output string. I guess that would need to be implemented in the UI code. - format_
square_ root - Formats square root result into a human-readable display string.
- generate_
scaled_ random_ table - Generates a table of 8 scaled random numbers from a given base raw random value ($0 \dots 1$).
- generate_
unique_ random_ triplet - Generates a triplet of non-repeating random integers within $[min, max]$.
Faithfully reproduces the loop validation in sidecar
6r2. - integer_
divide - Performs integer division (quotient without remainder). Returns an error if dividing by zero or overflowing.
- modulo
- Computes integer remainder (modulo). Returns an error if dividing by zero or overflowing.
- multiply
- Performs multiplication of two floating-point numbers.
- play_
rps - Evaluates a Rock-Paper-Scissors turn outcome.
- power
- Performs exponentiation ($base^{exp}$).
- quotient_
and_ remainder - Computes both quotient and remainder for integer division. Faithfully models legacy Visual Basic modulo formatting logic.
- rectangle_
area - Calculates the area of a rectangle given base and height ($base \cdot height$).
- rectangle_
perimeter - Calculates the perimeter of a rectangle ($2 \cdot (base + height)$).
- rps_
choice_ from_ int - Converts integer code ($1 \dots 3$) to
RpsChoice. - scaled_
random - Computes a scaled random number value based on a base $[0.0, 1.0)$ input.
- square_
root - Computes the square root of a number. Supports negative inputs by returning an imaginary component representation.
- subtract
- Performs subtraction of two floating-point numbers.
- verify_
prime_ and_ factors - Checks prime status and calculates factors, matching legacy calculator interface.