Ballasi / num2words

Convert numbers like 42 to forty-two
https://crates.io/crates/num2words
Apache License 2.0
17 stars 9 forks source link

Support for any finite numbers #5

Closed Ballasi closed 1 year ago

Ballasi commented 2 years ago

Currently, the stack is limited to i64/f64.

The program needs to have support for bignum (any finite numbers).

arpankapoor commented 2 years ago

I would like to make an attempt to add support for this by using the traits from num_traits. Do you think that should work or do you have any other ideas?

Ballasi commented 2 years ago

I've been thinking of the way this is meant to be implemented and mostly used by the user. I usually tend to avoid dependencies on unnecessary crates that can be re-implemented and tailored to my own crates to prevent dependency hell.

I've come across num-traits before and saw it doesn't bring much dependencies so I think I am fine with using it, especially since it seems to fit our use case pretty well.

When it comes to usability however, I have been thinking of the use case for the user. The main ways this is going to be used (for big nums) is likely through strings, not the specific trait num-traits makes. If num-traits offer a From<String> or From<&str>, I am all in for this approach!

arpankapoor commented 2 years ago

Num does have from_str_radix. Also, the popular big num crates like num-bigint, rust-decimal and others implement this trait.

I'll give it a go since the approach looks fine to you.

Ballasi commented 1 year ago

Implemented in commit 7114e5fbbe007bbe78cc265c633df880bba0b1fb via lib num-bigfloat.