6/9/2023 0 Comments C string to bcdIt used to be very common on much older computer systems with primitive instruction sets, but not so much anymore. What you need to do is read the byte, then convert it back from BCD to decimal, before using it. So, if you were to read this byte from RAM (or from another component) and were expecting to get the decimal value of 37, you would actually get … 55. What is actually happening is that each digit of the number in its decimal form is being stored in a fixed number of bits … usually four or eight.įor example, if you needed to store the decimal number 37 in BCD, with four-bits reserved for each column, then it would be encoded like this: I hope this article will make things a bit clearer.īCD is where a value isn’t stored in RAM in a simple binary format, but instead in a sort-of half-binary-but-half-decimal way. If you’re familiar with converting between binary, decimal and hexadecimal then this is fairly straightforward … but if you’re just beginning to tinker with microcontrollers then you may find yourself at a loss. ![]() ![]() When tinkering with Arduinos, you’re going to come across quite a number of components that provide data out – or require data in – Binary Coded Decimal (BCD for short).
0 Comments
Leave a Reply. |