rust/tests/ui/floating_point_arithmetic.stderr
Krishna Veera Reddy c636c6a55b Add lints to detect inaccurate and inefficient FP operations
Add lints to detect floating point computations that are either
inaccurate or inefficient and suggest better alternatives.
2020-02-23 22:20:33 -08:00

175 lines
6.3 KiB
Plaintext

error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:12:13
|
LL | let _ = x.log(2f32);
| ^^^^^^^^^^^ help: consider using: `x.log2()`
|
= note: `-D clippy::inaccurate-floating-point-computation` implied by `-D warnings`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:13:13
|
LL | let _ = x.log(10f32);
| ^^^^^^^^^^^^ help: consider using: `x.log10()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:14:13
|
LL | let _ = x.log(std::f32::consts::E);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:15:13
|
LL | let _ = x.log(TWO);
| ^^^^^^^^^^ help: consider using: `x.log2()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:16:13
|
LL | let _ = x.log(E);
| ^^^^^^^^ help: consider using: `x.ln()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:19:13
|
LL | let _ = x.log(2f64);
| ^^^^^^^^^^^ help: consider using: `x.log2()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:20:13
|
LL | let _ = x.log(10f64);
| ^^^^^^^^^^^^ help: consider using: `x.log10()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:21:13
|
LL | let _ = x.log(std::f64::consts::E);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()`
error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:26:13
|
LL | let _ = (1.0 + x).ln();
| ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()`
error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:27:13
|
LL | let _ = (1.0 + x * 2.0).ln();
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x * 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:28:13
|
LL | let _ = (1.0 + x.powi(2)).ln();
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(2).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:29:13
|
LL | let _ = (1.0 + x.powi(2) * 2.0).ln();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x.powi(2) * 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:30:13
|
LL | let _ = (1.0 + (std::f32::consts::E - 1.0)).ln();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `((std::f32::consts::E - 1.0)).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:37:13
|
LL | let _ = (1.0 + x).ln();
| ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()`
error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:38:13
|
LL | let _ = (1.0 + x * 2.0).ln();
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x * 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:39:13
|
LL | let _ = (1.0 + x.powi(2)).ln();
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(2).ln_1p()`
error: exponent for bases 2 and e can be computed more efficiently
--> $DIR/floating_point_arithmetic.rs:48:13
|
LL | let _ = 2f32.powf(x);
| ^^^^^^^^^^^^ help: consider using: `x.exp2()`
|
= note: `-D clippy::slow-floating-point-computation` implied by `-D warnings`
error: exponent for bases 2 and e can be computed more efficiently
--> $DIR/floating_point_arithmetic.rs:49:13
|
LL | let _ = std::f32::consts::E.powf(x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()`
error: square-root of a number can be computer more efficiently
--> $DIR/floating_point_arithmetic.rs:50:13
|
LL | let _ = x.powf(1.0 / 2.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()`
error: cube-root of a number can be computer more efficiently
--> $DIR/floating_point_arithmetic.rs:51:13
|
LL | let _ = x.powf(1.0 / 3.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()`
error: exponent for bases 2 and e can be computed more efficiently
--> $DIR/floating_point_arithmetic.rs:54:13
|
LL | let _ = 2f64.powf(x);
| ^^^^^^^^^^^^ help: consider using: `x.exp2()`
error: exponent for bases 2 and e can be computed more efficiently
--> $DIR/floating_point_arithmetic.rs:55:13
|
LL | let _ = std::f64::consts::E.powf(x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()`
error: square-root of a number can be computer more efficiently
--> $DIR/floating_point_arithmetic.rs:56:13
|
LL | let _ = x.powf(1.0 / 2.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()`
error: cube-root of a number can be computer more efficiently
--> $DIR/floating_point_arithmetic.rs:57:13
|
LL | let _ = x.powf(1.0 / 3.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()`
error: (e.pow(x) - 1) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:62:13
|
LL | let _ = x.exp() - 1.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`
error: (e.pow(x) - 1) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:63:13
|
LL | let _ = x.exp() - 1.0 + 2.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`
error: (e.pow(x) - 1) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:69:13
|
LL | let _ = x.exp() - 1.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`
error: (e.pow(x) - 1) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:70:13
|
LL | let _ = x.exp() - 1.0 + 2.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`
error: aborting due to 28 previous errors