5 ms·
This was one thing COBOL got right: built in support for a DECIMAL data type.
by a_c_s 8y ago
This was one thing COBOL got right: built in support for a DECIMAL data type.
- prevedmedved 8y agoDon't be stupid. A "decimal" type is a floating-point number, just with a different base. It solves none of the underlying problems. (Which is why, incidentally, nothing made in this millennium supports it.)
- christophilus 8y agoIt’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.
- Symmetry 8y agoDecimal 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 https://en.wikipedia.org/wiki/Decimal_floating_point
- ekimekim 8y agoBoth 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.
- deleted 8y ago[deleted]
- vanderZwan 8y agoGiven 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 ;))
- michaelcampbell 8y agoProbably implementation dependent, but the COBOL I used that put me through college used some variation of BCD (binary coded decimal).
- coldtea 8y agoCobol uses fixed point decimal
- int_19h 8y agoIn 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.
- vvern 8y agoFixed – Fixed-place decimal math library for Go (github.com) https://news.ycombinator.com/item?id=18559625 https://news.ycombinator.com/item?id=18559625