BCD - Binary Coded Decimal - Base 10 Inside Base 2 - Simply Put

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Just showing off my geek cred here ... in ye olden days when COBOL was prominent, BCD was quite prevalent.



Although you could store two digits to a byte, I don't think that's the way it's normally done. It's quite inefficient to do it like that. IEEE 754-2008 specifies a method of storing BCD which is much more compact. The idea of a BCD standard library for C++ has been floating around (if you'll forgive the pun) for many years now, but has never been made into a standard. There are, of course, BCD libraries out there, albeit they seem awkward to use. The GCC compiler does have decimal libraries as an extension, although that may be inconvenient if you want compiler portability.


Alas, it looks as though C++20 won't have decimal support, even though creaky old languages like COBOL have had them since the 1950's, or thereabouts.

zetaconvex