Closed hoodie closed 8 years ago
Hey I appreciate the feedback and work you've put in! I've actually spent the past few days working on an RSA implementation in Rust, which uses BigUints. It got me thinking about the currency library and I was just considering switching to BigInts. I'll spend some time this weekend putting that and adding some use-cases, such as applying taxes. Stay tuned and I'll let you know when I publish that!
If you have any more ideas, let me know!
Thanks again, Tyler
I have published a new version that now uses BigInt
to track the coin. It implements more traits, is more robust in the string parsing and formatting, and handles some conversion and float multiplication. I have not solved the precision problem, however. Feel free to take a look at what I've published. I think rounding is the way to go, and I am very open to ideas about how to round the BigInt
during multiplication. Perhaps I'll ask for help from that forum.
Cool thanks, I'll give it a firm check tomorrow :+1:
Hey, sorry, didn't have time so far to check it out.
I still feel about unsure about floats, especially where you multiply with f32
.
I was not able to hack up a test case where this produces false results, but there are cases where long floating point numbers produce garbage.
I've got a lot of unhappiness with this last release. Right now I'm working on porting decimal from C# over to Rust, then I plan on using that to, once again, rewrite the currency library.
:+1: There is a decimal crate, unfortunately it does not compile on stable since it uses (now no longer) unstable features. Unfortunately the author has not reacted to my issue yet :cry:
Update: I forked it here. I think your approach using integers for storing is pretty good, only in the places where you have to multiply with decimal numbers you should restrict their types. That's a cool thing about Rust, you could implement multiplication/division solely for Decimals and leave the rest as integers.
Hi there, I've been working with my one fork of this lib for a while, to which I had added to possibility to multiply with
f64
, to deal with taxes. However, I'm not sure if this is really a good idea. Alternatively this could use something like aBigInt
orBigRational
from num.. I'm also not sure about the operation to turn the resulting floats back intoi64
, whether or not to useceil()
,floor()
or justround()
.If you have no strong opinion about this I would ask someone at the Rust users forum for participation.