I'm not an expert but a finance library without a choice of rounding modes and using floating point for division and multiplication is a bit strange? Why those decisions?
Despite what everyone says, I've spoken to several different people at several different highly-regarded banks who say that they do, in fact, use floating point for money amounts in some of their systems. What experience do people who work in banks have?
Fixed – Fixed-place decimal math library for Go
31–40 of 73 posts
Re: Fixed – Fixed-place decimal math library for Go
#32Dear moderators it is called Go, from the github description, "fixed decimal place math library for Go".
"Go" was such a poor language name choice, it pretty much goes by "Golang" to make it easier to search, etc.
Re: Fixed – Fixed-place decimal math library for Go
#33It'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.
They have it in COBOL,which uses binary coded decimals to represent the number (1 decimal per nibble) so numbers like 0.3 can be represented without loss of accuracy. It was abandoned in favour of IEEE754.
Re: Fixed – Fixed-place decimal math library for Go
#34I'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).
Floating point multiplication can be faster than integer multiplication on modern CPUs. Check out this thread for lots of info! https://stackoverflow.com/q/2550281/164234
You have to ask, what do you even mean if you use floating point for representing money?
If you use floating point, the whole point is that you want the behaviour
1e100 = 1e100 + 1
This is exactly what you want for many analysis and decision making problems, but it is a dangerous default.
Re: Fixed – Fixed-place decimal math library for Go
#35Dear moderators it is called Go, from the github description, "fixed decimal place math library for Go".
Golang is the accepted label used for titles and other communications for disambiguations. Note the domain name that hosts the project.
You can watch Rob Pike publicly correcting someone at the end of his "Go 2 Draft Specifications" session during Q&A.
Re: Fixed – Fixed-place decimal math library for Go
#36I'm not an expert but a finance library without a choice of rounding modes and using floating point for division and multiplication is a bit strange? Why those decisions?
Despite what everyone says, I've spoken to several different people at several different highly-regarded banks who say that they do, in fact, use floating point for money amounts in some of their systems. What experience do people who work in banks have?
Running option trading models with BigDecimal is unproductive. However, when the calculations are done, we store the results back as decimal representation.
Re: Fixed – Fixed-place decimal math library for Go
#37You'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
#38Earlier quoted context omitted.
"Go" was such a poor language name choice, it pretty much goes by "Golang" to make it easier to search, etc.
I'm not sure Nim, Crystal, Rust, D (or C, C++) are that much better for searchability.