Binary coded decimal: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(Added FreeBasic)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
Line 1,182:
 
In what follows, the hex prefix '0x' is simply a way of representing BCD literals and has nothing to do with hexadecimal as such.
<syntaxhighlight lang="ecmascriptwren">import "./check" for Check
import "./math" for Int
import "./str" for Str
Line 1,272:
0x99 + 1 = 0x100 or, in unpacked BCD, 100100001001 + 1 = 10000000000000000
</pre>
 
=={{header|Z80 Assembly}}==
The <code>DAA</code> function will convert an 8-bit hexadecimal value to BCD after an addition or subtraction is performed. The algorithm used is actually quite complex, but the Z80's dedicated hardware for it makes it all happen in 4 clock cycles, tied with the fastest instructions the CPU can perform.
9,476

edits