https://medium.com/@bellmar/is-cobol-holding-you-hostage-with-math-5498c0eb428b
Face it: nobody likes fractions, not even computers.
When we talk about COBOL the first question on everyone's mind is always Why are we still using it in so many critical places? Banks are still running COBOL, close to 7% of the GDP is dependent on COBOL in the form of payments from the Centers for Medicare & Medicaid Services, The IRS famously still uses COBOL, airlines still use COBOL (Adam Fletcher dropped my favorite fun fact on this topic in his Systems We Love talk: the reservation number on your ticket used to be just a pointer), lots of critical infrastructure both in the private and public sector still runs on COBOL.
Why?
The traditional answer is deeply cynical. Organizations are lazy, incompetent, stupid. They are cheap: unwilling to invest the money needed upfront to rewrite the whole system in something modern. Overall we assume that the reason so much of civil society runs on COBOL is a combination of inertia and shortsightedness. And certainly there is a little truth there. Rewriting a mass of spaghetti code is no small task. It is expensive. It is difficult. And if the existing software seems to be working fine there might be little incentive to invest in the project.
But back when I was working with the IRS the old COBOL developers used to tell me: "We tried to rewrite the code in Java and Java couldn't do the calculations right."
[Ed note: The referenced article is extremely readable and clearly explains the differences between floating-point and fixed-point math, as well as providing an example and explanation that clearly shows the tradeoffs.]
(Score: 2) by DannyB on Wednesday September 18 2019, @01:54PM
For simple arithmetic, round should never be an allowed operation. That is the virtue of integers. It exactly models what currency has always been. Floating point is fantastic if I'm plotting a course to pluto, or doing statistical calculations, or doing 3D rendering and many, many other applications.
I won't go on about it, but IMO, floating point has no place when representing currency. (Possibly useful for certain intermediate calculations, but then the result is back to a currency value.) Integer arithmetic (+, -, *, /) is exact. (Division has an exact quotient and remainder.) Converting to / from string representation is exact. The rest of the industry figured this out in the 1970's. Possibly even 1960's.
Use floating point for money if you want to. But it probably won't happen on any real commercial type of project. It's the wrong tool for the job.
I use Java, as do many others, for the type of work I do, because it is the right tool. (I didn't say perfect. But its combination of attributes is great.) And developer productivity is the major thing to optimize for now. Complain about it if you must, but it is deeply entrenched. As is COBOL -- and I dislike COBOL, but I understand WHY it is.
OTOH, Other people use C and C++ for certain things which they are exceedingly good at.
Use the right tool for the right job.
Young people won't believe you if you say you used to get Netflix by US Postal Mail.