Does anyone still use BCD? - Page 1
Forum section: electronics / general

author: Analog Kid
author_rank: Super Contributor
timestamp: May 27, 2025, 08:03:22 pm
content: Question came up in a different forum.Does anyone still use the BCD format anymore? At least in data files (or even internally).My guess™® is that it went out when we stopped using old IBM mainframes (System/360 and such).

author: bdunham7
author_rank: Super Contributor
timestamp: May 27, 2025, 08:22:34 pm
content: Quote from: Analog Kid on May 27, 2025, 08:03:22 pmCOBOL uses BCD, so if you are running a COBOL emulator you might be using BDC. Since IBM mainframes are still around (even some "old" ones) and people still are running COBOL, they probably still have BCD structures in some cases. There probably wouldn't be any big push to eliminate it.

author: TimFox
author_rank: Super Contributor
timestamp: May 27, 2025, 08:40:33 pm
content: In 1967, the first computer I used was an IBM 1620, designed for educational institutions.It used BCD representation of values internally, and was an early transistorized system from IBM.https://paul.mcnabbs.org/ibm1620/which has a link to the actual manuals.The usual output device was an IBM typewriter: mean sophomores would hit a carriage return while a freshman was compiling his Fortran card deck, which sounded like an upcoming compile error.

author: ataradov
author_rank: Super Contributor
timestamp: May 27, 2025, 09:11:19 pm
content: ST's MCU use it in RTC. It is exceptionally stupid, since all the driver implementations just convert it into ints and back.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 27, 2025, 11:40:33 pm
content: I am guessing that it may still be used in "arbitrary length" number systems (Or they use packed bcd).Also, when converting numbers to a LUT for example for 7-segment display encoding the array index is pretty much BCD.

author: brucehoult
author_rank: Super Contributor
timestamp: May 28, 2025, 12:40:31 am
content: It could still make sense to use BCD on microcontrollers with very little memory or MHz for things such as remaining time display on a microwave oven or similar, so that you don't have to convert some binary integer of the number of seconds to HH:MM:SS every time, especially if you don't have multiply or divide instructions.But in many such situations it would make just as much or more sense to:- store one digit 0-9 per byte or register instead of one digit per nybble- store one digit per byte or register as '0'-'9' (48-57)- store HH as binary in one byte, MM as binary in another, SS as binary in another, as it is easy to convert two digit numbers from binary to decimal (including just by repeated subtraction of 10).

author: jpanhalt
author_rank: Super Contributor
timestamp: May 28, 2025, 04:20:42 am
content: Mitutoyo and probably other manufacturers use BCD in its SPC and U-Wave protocols for measuring. My NC lathe control (discussed elsewhere here) uses BCD. It was easier and probably faster to just go with BCD than to keep converting back and forth.According to Google it is still used in the financial sector.EDIT:According to Grok, TI also uses BCD in its calculators:Quote

author: brucehoult
author_rank: Super Contributor
timestamp: May 28, 2025, 04:48:32 am
content: Quote from: jpanhalt on May 28, 2025, 04:20:42 amBack in the days of the 68020 and 80386 when I was working for financial companies (stockbroking, FX etc) I used double precision FP in cents for all calculations. Exact calculations up to $90,071,992,547,409.92 was more than enough for my employers. I've been told some businesses are legally obligated to work in 4 decimal places of cents (6 decimal places of dollars), which would give an exact calculation range of $9,007,199,254.740992 which is probably not enough for that same kind of business. Now of course we all have fast 64 bit integers which give another couple of digits. And binary to decimal conversion on modern CPUs is faster than most I/O devices.Well, I just checked on my Linux box. Using printf() to print one billion different near max size uint64_t (and newlines) took 30 seconds, producing 21GB of output, 700MB/sec. So, ok, SSDs are faster than that. But I was only using one core and I have 24 :-) Or, I could have used SIMD.

author: jpanhalt
author_rank: Super Contributor
timestamp: May 28, 2025, 09:50:09 am
content: @brucehoultRe: two decimal placesWhen I was still in training, there was quite a flap about some big financial entities doing that and skimming the fractional pennies for their own pockets. $0.005 (on average) times a billion adds up.Re: one BCD per byte (instead of being packed)That's exactly what Mitutoyo SPC does. Each reading, which is only about once every 40ms, is 13 bytes, of which bytes 6-11 are actual BCD. The rest are codes for sign, units, where to put the decimal, and where to start the frame. See:http://www.matronics.com/cncscale/DiagramRev2.pdfI wasn't aware of the Starrett protocol, which goes a step further and uses ASCII.As an aside, if you ever visit PicList (mostly PIC Assembly -- now inactive), Scott Datallo would use ASCII for constants in his routines. I suspect he did that just for fun.