equality

Precise

When using equality, you can be safe knowing that
your code is as precise as floating-point precision should be.

Whatever calculation you want to perform, generate them through
the Expression type and when you finally want the result, just
utilize the evaluate() function. It'll return a f64 (or Double
in C/C++ and Java lingo. )

let expr1 = Expression::from(3);
let expr2 = Expression::from(2);
let expr3 = expr1 + expr2; // addition

// prints out "(3 + 2) = 5"
println!("{} = {}", expr3, expr3.evaluate());

let expr4 = Expression::from(15);
let expr5 = Expression::from(61);
let expr6 = expr3 * (expr4 / expr5);

// prints out "((3 + 2) * (15 / 61)) = 1.2295081967213115"
println!("{} = {}", expr6, expr6.evaluate());

Performant

If you compare the different implementations of algebra in equality
one can see that one is using f64's and the other one is
using Expression's. This difference is to offer performance or
precision, as well as exposing this capability to the developer.

let expr1 = Expression::from(3);
let expr2 = Expression::from(2);
let expr3 = expr1 + expr2; // addition

// prints out "(3 + 2) = 5"
println!("{} = {}", expr3, expr3.evaluate());

let expr4 = Expression::from(15);
let expr5 = Expression::from(61);
let expr6 = expr3 * (expr4 / expr5);

// prints out "((3 + 2) * (15 / 61)) = 1.2295081967213115"
println!("{} = {}", expr6, expr6.evaluate());

Expressive

When using equality, you can be safe knowing that
your code is as precise as floating-point precision should be.

Whatever calculation you want to perform, generate them through
the Expression type and when you finally want the result, just
utilize the evaluate() function. It'll return a f64 (or Double
in C/C++ and Java lingo. )

let expr1 = Expression::from(3);
let expr2 = Expression::from(2);
let expr3 = expr1 + expr2; // addition

// prints out "(3 + 2) = 5"
println!("{} = {}", expr3, expr3.evaluate());

let expr4 = Expression::from(15);
let expr5 = Expression::from(61);
let expr6 = expr3 * (expr4 / expr5);

// prints out "((3 + 2) * (15 / 61)) = 1.2295081967213115"
println!("{} = {}", expr6, expr6.evaluate());

About

Equality is an expressive, robust and fast math library for the Rust programming language and is used in the Titanium game engine.

Join our mailing lists for the latest information


Links