m3m0ry / fixedpoint

Decimal fixed point type
Boost Software License 1.0
6 stars 3 forks source link

Fix binary ops and simplify string ctor #3

Closed schveiguy closed 4 years ago

schveiguy commented 4 years ago

Here are some changes I needed for my code base. I also simplified the ctor to be one to call.

I didn't do mod operator, because I'm not familiar with what should be expected for a decimal.

I also didn't do multiplication and division between fixed points because technically, you should multiply the factors together. e.g. 0.01 * 0.01 == 0.0001, and division should divide the factors (I think, division is tricky). So you may want to have e.g. typeof(Fixed!2.init * Fixed!2.init) == Fixed!4.

In any case, I don't need those features for my purposes. I'm now using your library in my code. If I find anything else, I'll post an issue or PR.

schveiguy commented 4 years ago

I will add an opBinary + and - for Fixed of same scaling

Those are already in there.