Hex or Dec?
MichelB
Posts: 154
Hi Specialists in Code, in the BASIC Stamp Syntax and Reference Manual 2.2, page 112, it's written: "It may be clearer to express the */ multiplier in hex - as $0180 - since hex keeps the contents of the upper and lower bytes separate. Here's an example:"...
If you replace in the example $0180 (that keeps the contents of the upper and lower bytes separate) by the Dec value i.e. 384 the result is the same. Where is the advantage of "hex" explained above? Thank you in advance.
·
If you replace in the example $0180 (that keeps the contents of the upper and lower bytes separate) by the Dec value i.e. 384 the result is the same. Where is the advantage of "hex" explained above? Thank you in advance.
·
Comments
Post Edited (Marz Krishna) : 10/10/2009 8:24:14 PM GMT
So if you put it into dec, you would have to convert to base 2 (or power of 2) to find out which are the upper and which is the lower bytes, then convert each back into dec to get the multiplier. This way, it just keeps a step out.
Hexadecimal, decimal, octal, binary, are different ways for you to represent numbers IN YOUR MIND. Each has advantages and disadvantages. Hexadecimal makes it easier for you to see quickly the contents of the upper and lower nibbles of a byte. Decimal makes it easier to do arithmetic in your head, because you're used to it. Binary makes it easy for you to think in terms of individual bits.
The machine doesn't care. It goes along blindly, doing whatever you tell it to do, never adding any insights of its own, not knowing what it does, not caring -- just like Democrats.
-- Carl
P.S. that last line is mostly stolen from the Bob Hope movie "Ghost Busters".
.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net