I am making a project in which I am using the stm32f3discovery board and need to know the square root of a a decimal number, there is obviously the function in the std library but as I cannot use the std library, is there a way in which I can find the square root without it?
When you say "decimal", do you mean
libm crate has pure-rust implementations of most of these functions.
What do you mean by “decimal number” and which square root “function” in
std are you referring to?
In case you mean floating point numbers,
.sqrt() is a method on
f32, so it ought to work with or without
std (as far as I can tell).
It does not work without
std, and I wish the documentation reflected this.
Okay, nevermind, I never used
#![no_std] myself before. The documentation is indeed pretty confusing about this. What is the fundamental reason why those methods are not provided with
For some targets, there are native instructions for these methods which LLVM will try to use, but in general it may have to fall back to the system
libm -- which may not exist in
The micromath crate also provides sqrt that is optimized for embedded systems (but less accurate than libm's)
Yeah this crate is perfect, thank you
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.