Binary coded decimal: Difference between revisions

Content added Content deleted
(Added C++ solution)
Line 1,013: Line 1,013:
100
100
</pre>
</pre>
=={{header|RPL}}==
{{trans|Forth}}
{{works with|Halcyon Calc|4.2.7}}
≪ #666666666666666h +
DUP2 XOR ROT ROT + SWAP OVER XOR
NOT #1111111111111110h AND
DUP SR SR SWAP SR SR SR OR
- #FFFFFFFFFFFFFFFh AND
≫ 'ADBCD' STO
≪ NOT 1 + #FFFFFFFFFFFFFFFh AND DUP 1 -
1 XOR OVER XOR NOT #1111111111111110h AND
DUP SR SR SWAP SR SR SR OR -
'NGBCD' STO
≪ NGBCD ADBCD ≫
'SUBCD' STO
64 STWS HEX
#19 #1 ADBCD
#99 #1 ADBCD
#30 #1 SUBCD
{{out}}
<pre>
3: #20h
2: #100h
1: #29h
</pre>

=={{header|Rust}}==
=={{header|Rust}}==
Based on the Forth implementation re: how to implement BCD arithmetic in software. Uses operator overloading for new BCD type.
Based on the Forth implementation re: how to implement BCD arithmetic in software. Uses operator overloading for new BCD type.
Line 1,070: Line 1,100:
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
</pre>
</pre>

=={{header|Wren}}==
=={{header|Wren}}==
{{libheader|Wren-check}}
{{libheader|Wren-check}}