Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the libm crate for a full Float on no_std #75

Closed
Tracked by #1
cuviper opened this issue Jul 16, 2018 · 8 comments
Closed
Tracked by #1

Use the libm crate for a full Float on no_std #75

cuviper opened this issue Jul 16, 2018 · 8 comments

Comments

@cuviper
Copy link
Member

cuviper commented Jul 16, 2018

Currently, num_traits::Float is only available with std, and no_std only has the more limited FloatCore without all of transcendental functions like sqrt, sin, etc. The new libm crate might be the way out of this, as an optional dependency to get Float on no_std too!

There's also Real and the signed and floating-point Pow (mapping to powi and powf) which all require std now, and should be feasible with libm. I'm not sure about MulAdd and MulAddAssign though.

@vks
Copy link
Contributor

vks commented Jul 17, 2018

libm is not ready yet, it panics with overflows in debug mode.

@cuviper
Copy link
Member Author

cuviper commented Jul 17, 2018

Sure, we can hold off until it's more ready -- I'm not in any rush. It could still be useful to do early exploration though, to identify any other shortcomings that libm might want to address.

chrysn added a commit to chrysn-pull-requests/i2cdev-sensors that referenced this issue Aug 27, 2018
* Numeric traits are replaced with their core counterparts.
* Errors don't need to implement std:error::Error any more.
* Altitude-from-pressure was commented out until there is a libm
  implementation of powf ([1], probably)

[1]: rust-num/num-traits#75
bors bot added a commit that referenced this issue Sep 30, 2019
99: Revive Float+Real in no_std thanks to libm r=cuviper a=yoanlcq

Greetings,

This is a hopeful fix for #75.  
Basically: Add `libm` as an optional dependency, and handle three possible cases depending on which features are enabled:
- std and libm: std is used;
- std and not libm: std is used;
- libm and not std: libm and FloatCore are used.

It was briefly mentioned that `libm` wasn't ready yet, but this was months ago, and I believe it is better not to wait for too long.  
If anything, bugs in `libm` should be fixed in `libm`; `num-traits` is only delegating its implementations to it; not to mention that the more `libm` is used, the likelier issues are to be found and hopefully fixed.

Thanks in advance!

Co-authored-by: Yoan Lecoq <yoanlecoq.io@gmail.com>
Co-authored-by: Josh Stone <cuviper@gmail.com>
@malobre
Copy link

malobre commented Oct 20, 2019

Since #99 was merged shouldn't this be closed ?

Edit: If closing please also consider publishing a new version this would permit updating other crates (Ogeon/palette#145) thanks :)

@korken89
Copy link

Hi, please make a release including #99 this is a key component for a library I'm writing and I would love to have this!

CC @cuviper

@cuviper
Copy link
Member Author

cuviper commented Oct 28, 2019

I will try to get to it this week.

@CryZe
Copy link
Contributor

CryZe commented Nov 11, 2019

What's the status of this? It's been two weeks. Sorry for maybe pinging this early, but this is my last blocker (and it looks like a lot of other crates are waiting too).

@korken89
Copy link

Same here, this is the only thing that is missing for me as well

@cuviper
Copy link
Member Author

cuviper commented Nov 13, 2019

Sorry for the delay -- num-traits 0.2.9 is now published!

@cuviper cuviper closed this as completed Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants