I'm a bit surprised to see floating point being used for multiplication, division etc. I would have expected to see this implemented with integers as well (with each operation changing the position of the point).
Fixed – Fixed-place decimal math library for Go
21–30 of 73 posts
Re: Fixed – Fixed-place decimal math library for Go
#22Earlier quoted context omitted.
I work in Finance, I don't use float, and I suggest you never do either.
As a concrete example, someone was running a massive online FFI for predicting the value of derivatives, and they were doing it in the real domain and using doubles on GPUs for monetary values. Where they doing it 'wrong' then? I don't know much about finance myself.
However, if you're doing things like high-frequency trading systems or machine learning stuff with massive amounts of data, then performance really does matter, and using floating point is entirely reasonable. If you're making systems like that, you're hopefully aware of the limitations of floating point and know how to use them safely.
Re: Fixed – Fixed-place decimal math library for Go
#23Earlier quoted context omitted.
With a bank balance on a computer.
Can computer bank balances store fractional cents right now? At least before, this was not possible.
Re: Fixed – Fixed-place decimal math library for Go
#24You'll never get good performance without using assembly. GMP probably walks all over this. Even my own bignum library probably walks all over it for addition and subtraction.
Re: Fixed – Fixed-place decimal math library for Go
#25You'll never get good performance without using assembly. GMP probably walks all over this. Even my own bignum library probably walks all over it for addition and subtraction.
Re: Fixed – Fixed-place decimal math library for Go
#26Dear moderators it is called Go, from the github description, "fixed decimal place math library for Go".
Re: Fixed – Fixed-place decimal math library for Go
#27You'll never get good performance without using assembly. GMP probably walks all over this. Even my own bignum library probably walks all over it for addition and subtraction.
Where can we find your bignum library?
Re: Fixed – Fixed-place decimal math library for Go
#28Earlier quoted context omitted.
Can computer bank balances store fractional cents right now? At least before, this was not possible.
The question is can computers do arbitrary precision arithmetic. Technically you'd need infinite memory, but if you use fractions to represent amounts, as is correct, then practically speaking, yes you can. One accounting system that uses fractions is ledger[0]. [0] https://www.ledger-cli.org/
Fractions do little for interest rates, which are transcendental functions and sometimes even irrational.
Re: Fixed – Fixed-place decimal math library for Go
#29Dear moderators it is called Go, from the github description, "fixed decimal place math library for Go".
Re: Fixed – Fixed-place decimal math library for Go
#30It's always struck me as strange than finance folk don't want correct math. They want math that matches the coins in their pocket. If I am owed 2.575% on $3425956.57 for 245 months, why not get the correct sum instead of some rounded monthly sum added up? Its just strange.