ios_calculator

A simple iOS calculator implementation

3 unstable releases

0.2.1 Apr 22, 2023
0.2.0 Apr 21, 2023
0.1.0 Apr 21, 2023

#1030 in Math

28 downloads per month

MIT/Apache

23KB
493 lines

Rusty iOS Calculator

An implementation of the basic iOS calculator featuring:

  • DMAS (division, muliplication, addition, subtraction) operations
  • Decimalisation
  • Memory of last calculation
  • Percentage conversion

Example

use ios_calculator::{Calculator, Operator};

let mut calc = Calculator::new();

calc.submit_number(1);
calc.submit_decimal();
calc.submit_number(2);
calc.submit_operator(Operator::add());
calc.submit_number(2);
calc.submit_equals();

assert_eq!(
    calc.output().value(),
    3.2,
);

assert_eq!(
    calc.output().to_string(),
    "3.2",
); 

lib.rs:

Rusty iOS Calculator

An implementation of the basic iOS calculator featuring:

  • DMAS (division, muliplication, addition, subtraction) operations
  • Decimalisation
  • Memory of last calculation
  • Percentage conversion

Example

use ios_calculator::{Calculator, Operator};

let mut calc = Calculator::new();

calc.submit_number(1);
calc.submit_decimal();
calc.submit_number(2);
calc.submit_operator(Operator::add());
calc.submit_number(2);
calc.submit_equals();

assert_eq!(
    calc.output().value(),
    3.2,
);

assert_eq!(
    calc.output().to_string(),
    "3.2",
); 

Dependencies

~360KB
~10K SLoC