RNG command line utils
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1016 B

use super::*;
use getrandom::*;
pub fn range(start: f64, end: f64, mut repeat: usize) -> Result<(), Error>
{
if repeat < 1 {
repeat = 1;
}
for _ in 0..repeat {
let value = double()?;
println!("{}", start + (value * (end-start)));
}
Ok(())
}
pub fn round(start: f64, end: f64, mut repeat: usize) -> Result<(), Error>
{
if repeat < 1 {
repeat = 1;
}
for _ in 0..repeat {
let value = double()?;
println!("{}", ((start + (value * (end-start)))).round() as i64);
}
Ok(())
}
pub fn ceil(start: f64, end: f64, mut repeat: usize) -> Result<(), Error>
{
if repeat < 1 {
repeat = 1;
}
for _ in 0..repeat {
let value = double()?;
println!("{}", (start + (value * (end-start))).ceil() as i64);
}
Ok(())
}
pub fn floor(start: f64, end: f64, mut repeat: usize) -> Result<(), Error>
{
if repeat < 1 {
repeat = 1;
}
for _ in 0..repeat {
let value = double()?;
println!("{}", (start + (value * (end-start))).floor() as i64);
}
Ok(())
}