]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/float_math.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / run-pass / float_math.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(core_intrinsics)]
12
13 use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast};
14
15 #[inline(never)]
16 pub fn test_operations(a: f64, b: f64) {
17 // make sure they all map to the correct operation
18 unsafe {
19 assert_eq!(fadd_fast(a, b), a + b);
20 assert_eq!(fsub_fast(a, b), a - b);
21 assert_eq!(fmul_fast(a, b), a * b);
22 assert_eq!(fdiv_fast(a, b), a / b);
23 assert_eq!(frem_fast(a, b), a % b);
24 }
25 }
26
27 fn main() {
28 test_operations(1., 2.);
29 test_operations(10., 5.);
30 }