Is there a crate that provides function versions of f64
methods? I'd like to be able to write, e.g., sqrt(x)
instead of f64::sqrt(x)
or x.sqrt()
.
It's probably an overkill to use a crate for it. You can make these yourself:
#[inline(always)]
fn sqrt(x: f64) -> f64 {
x.sqrt()
}
1 Like
Why not just implement root
function?
#[inline]
fn root(x: f64, base: f64) -> f64 {
unsafe {
core::intrinsics::powf64(x, 1.0 / base)
}
}
There are dozens of methods on f64
and I'd rather not write a trivial function for each one. I just used sqrt
as an example.
Sorry, my answer wasn’t for you. Anyway I recommend to use methods because it’s just more stylish and readable in most cases (we unfortunately don’t have a pipe operator)
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.