Live data from Hacker News

Fixed – Fixed-place decimal math library for Go

github.com

31–40 of 73 posts

Re: Fixed – Fixed-place decimal math library for Go

#31
post #2

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?

I used COBOL in a well known global American bank.

Re: Fixed – Fixed-place decimal math library for Go

#32
post #29
post #10

Dear 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.

I'm not sure Nim, Crystal, Rust, D (or C, C++) are that much better for searchability.

Re: Fixed – Fixed-place decimal math library for Go

#33

It'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.

I think that was a holdover of EBCDIC, an old IBM standard. In fact early IBM machines did BCD in their ALU.

Re: Fixed – Fixed-place decimal math library for Go

#34
post #21

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).

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

When people consider float vs int, performance is seldom a relevant factor.

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

#35
post #26
post #10

Dear 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.

A domain name is not a programming language name, oh look this cool stuff I have done in ISOCPP.

You can watch Rob Pike publicly correcting someone at the end of his "Go 2 Draft Specifications" session during Q&A.

https://www.youtube.com/watch?v=RIvL2ONhFBI

Re: Fixed – Fixed-place decimal math library for Go

#36
post #2

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?

We do use FP numbers for performance reasons occasionally, but we are well aware of their limitations, and when to normalize.

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

#37

You'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.

It's not a bignum library. It's just 64b integer fixed-point with a scale of 10^-7. So, perf-wise it's not going to have any issues, but it's also pretty easy to exceed the representable bounds.

Re: Fixed – Fixed-place decimal math library for Go

#38
post #32
post #29

Earlier 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.

They really are. "Go" as a word is in way heavier usage than any of those.

Re: Fixed – Fixed-place decimal math library for Go

#39
I work in the accounting space. In the current systems we develop today this would need to be able to handle trillions(up to 14 places) at least and most likely quadrillions(up to 17 spaces) These amounts happen already due to certain countries with high inflation levels.
Post reply on HN