User Tools

Site Tools

한국어

cubloc:bcd2bin:index

Bcd2Bin

Variable = BCD2BIN(bcdvalue)

Variable Variable to store results (returns Long)
bcdvalue BCD value to convert to binary

Bcd2Bin converts a BCD (Binary Coded Decimal) number into a normal binary number, CUBLOC BASIC's default number format. BCD is a way of expressing values as decimals. For example, the number 3451 in binary is as shown below:

3 4 5 1 0 D 7 B 0 0 0 0 1 1 0 1 0 1 1 1 1 0 1 1

The following is 3451 converted to BCD code. As you can see, each 4 bits represent one of the digits.

3 4 5 1 3 4 5 1 0 0 1 1 0 1 0 0 0 1 0 1 0 0 0 1

This command is useful when the user needs to convert a variable for a device such as a 7 segment display, or a real-time clock.

Dim A As Integer
A = Bcd2bin(&h1234)
Debug Dec A   ' Print 1234

See also Bin2Bcd

Go CUBLOC home

cubloc/bcd2bin/index.txt · Last modified: 2016/04/14 11:07 (external edit)