make float range more readable

This commit is contained in:
jacekpoz 2023-11-05 20:29:29 +01:00
parent fe3a534eff
commit 662d78be06
No known key found for this signature in database
GPG key ID: 94E812A8B12AAE3C

View file

@ -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);
// 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
(((b.start * multiplier) as i64)..((b.end * multiplier) as i64))
.map(|x| (x as f64) / multiplier)
{
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