In articles about COBOL, you sometimes see a claim that calculations were „more precise“ in COBOL. This might be the most impudent lie you will find around COBOL.
C, C++, C#, Java, Python and almost every other programming language are turing complete. To be turing complete, a programming language only needs to provide a very small instruction set: variables, addition, subtraction, jumps depending on equality-comparison or unrestricted loops (like while-loops).
The only languages that aren’t turing complete are languages that are specifically designed to be turing incomplete (like SQL).
All turing complete languages can do exactly the same calculations. It is mathematically impossible for COBOL to be „more precise“ than other languages! This claim is complete nonsense!
Fixed-Point vs. Floating-Point
What they are talking about is that COBOL represents rational numbers in decimal, fixed-point form whereas other languages let you choose between different representations like floating-point according to IEEE 754 („floats“) but also decimal fixed-point!
Floats are fast. CRAZY fast! Floating-point calculations often cost around 0 CPU-cycles, because compilers delegate these calculations to the FPU. Calculations in COBOL are much slower by the way, because COBOL calculates each digit individually.
Because of that, you’ll use floats whenever possible – but you shouldn’t use them to calculate amounts of money for example, because you’d get in all sorts of legal trouble if you misappropriated just a single cent as a result of the following:
Floats are binary rational numbers – humans think in decimal numbers. So sometimes you’d have to translate decimal rational numbers (like amounts of money) into floats – and this is where you get some problems, because for example the number 0.1 is repeating in binary representation.
COBOL has the same problem with numbers that are repeating in the decimal system. Go to https://www.tutorialspoint.com/compile_cobol_online.php and try the following code in COBOL:
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-A PIC 9V9. PROCEDURE DIVISION. COMPUTE WS-A = 1/3*3. DISPLAY WS-A. STOP RUN.
It will falsely display „0.9“, because in the decimal system, 1/3 is a repeating number. The calculation breaks down into 1/3*3 = 0.3*3 = 0.9 but this error is more understandable to a human who reads the output.
The more precise representation
If anything, COBOL computations are less precise than IEEE 754 Floating Point calculations, because in the cases where COBOL has an advantage, it has an advantage of maybe 0,000000000000000001%, whereas in cases where COBOL has a disadvantage, it has a disadvantage of easily 10% (as shown above).
And it makes sense that COBOLs representation is inferior, because COBOLs representation was hastily designed by a handfull of (self-professed) amateurs, whereas IEEE 754 Floating Point was designed by an international consortium of experts, with input by computer scientists and mathematicians from all over the world, over a timespan of more than 20 years.