]> git.proxmox.com Git - rustc.git/blob - src/test/ui/run-pass/numbers-arithmetic/float_math.rs
New upstream version 1.30.0~beta.7+dfsg1
[rustc.git] / src / test / ui / run-pass / numbers-arithmetic / 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 // run-pass
12 #![feature(core_intrinsics)]
13
14 use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast};
15
16 #[inline(never)]
17 pub fn test_operations(a: f64, b: f64) {
18 // make sure they all map to the correct operation
19 unsafe {
20 assert_eq!(fadd_fast(a, b), a + b);
21 assert_eq!(fsub_fast(a, b), a - b);
22 assert_eq!(fmul_fast(a, b), a * b);
23 assert_eq!(fdiv_fast(a, b), a / b);
24 assert_eq!(frem_fast(a, b), a % b);
25 }
26 }
27
28 fn main() {
29 test_operations(1., 2.);
30 test_operations(10., 5.);
31 }