Jump to content

Real constants and functions: Difference between revisions

(→‎{{header|Rust}}: Added Rust)
Line 1,796:
ceil: 2
Power: 2.28886641</pre>
 
 
=={{header|Rust}}==
<lang rust>#![allow(unused_assignments)]
use std::f64::consts::*;
fn main() {
// e (base of the natural logarithm)
let mut x = E;
// π
x = PI;
// square root
x = x.sqrt();
// logarithm (any base allowed)
x = x.ln();
// ceiling (smallest integer not less than this number--not the same as round up)
x = x.ceil();
// exponential (ex)
x = x.exp();
// absolute value (a.k.a. "magnitude")
x = x.abs();
// floor (largest integer less than or equal to this number--not the same as truncate or int)
x = x.floor();
// power (xy)
x = x.powf(x);
 
assert_eq!(x, 4.0);
}
 
=={{header|Scheme}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.