make float range more readable
This commit is contained in:
parent
fe3a534eff
commit
662d78be06
1 changed files with 6 additions and 5 deletions
11
src/main.rs
11
src/main.rs
|
@ -39,16 +39,17 @@ fn points_under_graph(
|
|||
fn get_sup(
|
||||
integral: &Integral<f64>
|
||||
) -> f64 {
|
||||
let multiplier = 1000.0;
|
||||
let b = &integral.bounds;
|
||||
let f = &integral.function;
|
||||
|
||||
let mut sup = f(b.start);
|
||||
|
||||
for i in
|
||||
(((b.start * multiplier) as i64)..((b.end * multiplier) as i64))
|
||||
.map(|x| (x as f64) / multiplier)
|
||||
{
|
||||
// needed to iterate over a float range with some step
|
||||
let multiplier = 1000.0;
|
||||
let start_int = (b.start * multiplier) as i64;
|
||||
let end_it = (b.end * multiplier) as i64;
|
||||
|
||||
for i in (start_int..end_it).map(|x| (x as f64) / multiplier) {
|
||||
let y = f(i);
|
||||
// for the π approximation f(-1) and f(1)
|
||||
// returned ∞, this if fixes that
|
||||
|
|
Loading…
Reference in a new issue