rust-decimal icon indicating copy to clipboard operation
rust-decimal copied to clipboard

support for num_trait::float::Float

Open julama opened this issue 4 years ago • 4 comments

Hi, Would it be possible to implement the trait num_traits::float::Float for Decimal?

julama avatar Jan 07 '21 15:01 julama

The more I think about this, the more I think I'll likely break the "float like" behavior into it's own internal feature crate/module. That way adding some features such as this becomes a little more trivial in nature and easier to reason with. Currently, as it stands, it doesn't make much sense however if I can do a little bit of refactoring of some of these features I think there is a world which allows this to fit into the library eco-system cleanly.

paupino avatar Jan 20 '21 17:01 paupino

That would be really nice! Do you have an estimate when something like that could be ready? I'm new to rust but if you could give me some advice on where/how to start with the implementation I'm also interested in contributing.

julama avatar Jan 21 '21 16:01 julama

The tricky part of this implementation is implementing some currently unsupported features. e.g. sin, cos, powf. It's feasible these could be unimplemented! however it'd be better if they weren't. It may be worth having this split into two tickets:

  1. Implement trigonometry functionality
  2. Implement #169

Once these are implemented, adding the float trait behind the maths feature would be fairly trivial.

paupino avatar Apr 23 '21 18:04 paupino

  1. Implement trigonometry functionality
  2. Implement https://github.com/paupino/rust-decimal/issues/169

This has now been done. Will this soon be implemented?

NatanFreeman avatar Sep 21 '22 05:09 NatanFreeman