News for hackers. Stuff that matters.
Re:Go 2, here we come by a_c_s on Thursday November 29, 2018 @12:37PM (#18561979)
This was one thing COBOL got right: built in support for a DECIMAL data type.
Re:Go 2, here we come by vvern on Thursday November 29, 2018 @10:24PM (#18566381)
Fixed – Fixed-place decimal math library for Go (github.com) https://news.ycombinator.com/item?id=18559625
[dead]
Re:Go 2, here we come by christophilus on Thursday November 29, 2018 @01:14PM (#18562352)
It’s been a while since I COBOLed, but if I recall, the COBOL decimal is similar to Currency types in languages like C#. (Maybe I’m misremembering.) If I’m right, though, it’s not a floating point number. It’s currency properly handled via integer math under the hood.
Re:Go 2, here we come by int_19h on Thursday November 29, 2018 @09:53PM (#18566231)
In C#, there's a "decimal" type. Which is exactly that - decimal floating-point. However, one catch about it is that it doesn't allow for the exponent that would place the decimal point somewhere outside of the representable digits of the number (i.e. unlike floats, the difference between any two decimals is never more than 1).

But it's still plenty useful, because it allows to accurately represent decimal fractional numbers, which is exactly what's needed in many domains, since humans work with decimal fractional numbers. Representing money would be one particular example.

Re:Go 2, here we come by Symmetry on Thursday November 29, 2018 @01:19PM (#18562401)
Decimal floating point is actually an established thing and part of the current IEEE 754 spec. I'm not too familiar with COBOL but pretty much any modern language will offer it through a library or compiler extension. Recent IBM Power processors even have hardware support.

https://en.wikipedia.org/wiki/Decimal_floating_point

Re:Go 2, here we come by ekimekim on Thursday November 29, 2018 @01:49PM (#18562695)
Both you and the parent are correct. Decimal floating point is a long-established thing, but the vast majority of "Currency" or "Decimal" data types in modern languages are arbitrary or fixed precision (to some configurable precision) which uses integer math under the hood.
Re:Go 2, here we come by vanderZwan on Thursday November 29, 2018 @01:48PM (#18562673)
Given the age of COBOL and the age of IEEE floating points, it would be very unlikely if it used a floating point number.

(And yes, I know that Conrad Zuse invented floating point over a century ago ;))

Re:Go 2, here we come by michaelcampbell on Thursday November 29, 2018 @03:18PM (#18563563)
Probably implementation dependent, but the COBOL I used that put me through college used some variation of BCD (binary coded decimal).
Re:Go 2, here we come by coldtea on Thursday November 29, 2018 @06:37PM (#18565231)
Cobol uses fixed point decimal