2020-02-28 07:31:41 +01:00
|
|
|
#[warn(clippy::suboptimal_flops)]
|
2020-02-28 21:40:13 +01:00
|
|
|
struct A {
|
|
|
|
a: f64,
|
|
|
|
b: f64
|
|
|
|
}
|
2020-02-28 07:31:41 +01:00
|
|
|
|
|
|
|
fn fake_abs1(num: f64) -> f64 {
|
|
|
|
if num >= 0.0 {
|
|
|
|
num
|
|
|
|
} else {
|
|
|
|
-num
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fake_abs2(num: f64) -> f64 {
|
|
|
|
if 0.0 < num {
|
|
|
|
num
|
|
|
|
} else {
|
|
|
|
-num
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-28 21:40:13 +01:00
|
|
|
fn fake_abs3(a: A) -> f64 {
|
|
|
|
if a.a > 0.0 {
|
|
|
|
a.a
|
|
|
|
} else {
|
|
|
|
-a.a
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-28 07:31:41 +01:00
|
|
|
fn fake_nabs1(num: f64) -> f64 {
|
|
|
|
if num < 0.0 {
|
|
|
|
num
|
|
|
|
} else {
|
|
|
|
-num
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fake_nabs2(num: f64) -> f64 {
|
|
|
|
if 0.0 >= num {
|
|
|
|
num
|
|
|
|
} else {
|
|
|
|
-num
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-28 21:40:13 +01:00
|
|
|
fn fake_nabs3(a: A) -> A {
|
|
|
|
A { a: if a.a >= 0.0 {
|
|
|
|
a.a
|
|
|
|
} else {
|
|
|
|
-a.a
|
|
|
|
}, b: a.b }
|
|
|
|
}
|
|
|
|
|
2020-02-28 07:31:41 +01:00
|
|
|
fn not_fake_abs1(num: f64) -> f64 {
|
|
|
|
if num > 0.0 {
|
|
|
|
num
|
|
|
|
} else {
|
|
|
|
-num - 1f64
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn not_fake_abs2(num: f64) -> f64 {
|
|
|
|
if num > 0.0 {
|
|
|
|
num + 1.0
|
|
|
|
} else {
|
|
|
|
-(num + 1.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn not_fake_abs3(num1: f64, num2: f64) -> f64 {
|
|
|
|
if num1 > 0.0 {
|
|
|
|
num2
|
|
|
|
} else {
|
|
|
|
-num2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-28 21:40:13 +01:00
|
|
|
fn not_fake_abs4(a: A) -> f64 {
|
|
|
|
if a.a > 0.0 {
|
|
|
|
a.b
|
|
|
|
} else {
|
|
|
|
-a.b
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn not_fake_abs5(a: A) -> f64 {
|
|
|
|
if a.a > 0.0 {
|
|
|
|
a.a
|
|
|
|
} else {
|
|
|
|
-a.b
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-28 07:31:41 +01:00
|
|
|
fn main() {}
|