Binary to Decimal Conversion

1 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€42.52
List Price:  €59.53
You save:  €17.01
£37.27
List Price:  £52.19
You save:  £14.91
CA$68.86
List Price:  CA$96.41
You save:  CA$27.55
A$75.34
List Price:  A$105.49
You save:  A$30.14
S$64.47
List Price:  S$90.27
You save:  S$25.79
HK$388.86
List Price:  HK$544.44
You save:  HK$155.57
CHF 39.78
List Price:  CHF 55.69
You save:  CHF 15.91
NOK kr508.40
List Price:  NOK kr711.80
You save:  NOK kr203.40
DKK kr317.68
List Price:  DKK kr444.77
You save:  DKK kr127.09
NZ$86.44
List Price:  NZ$121.02
You save:  NZ$34.58
د.إ183.58
List Price:  د.إ257.03
You save:  د.إ73.45
৳6,107.52
List Price:  ৳8,551.02
You save:  ৳2,443.49
₹4,549.73
List Price:  ₹6,369.99
You save:  ₹1,820.25
RM204.23
List Price:  RM285.94
You save:  RM81.71
₦72,591.97
List Price:  ₦101,634.57
You save:  ₦29,042.60
₨14,005.97
List Price:  ₨19,609.48
You save:  ₨5,603.51
฿1,575.72
List Price:  ฿2,206.14
You save:  ฿630.41
₺2,135.21
List Price:  ₺2,989.46
You save:  ₺854.25
B$270.67
List Price:  B$378.96
You save:  B$108.29
R839.85
List Price:  R1,175.86
You save:  R336
Лв83.15
List Price:  Лв116.42
You save:  Лв33.27
₩73,708.76
List Price:  ₩103,198.16
You save:  ₩29,489.40
₪160.81
List Price:  ₪225.14
You save:  ₪64.33
₱2,930.02
List Price:  ₱4,102.27
You save:  ₱1,172.24
¥7,740.31
List Price:  ¥10,837.05
You save:  ¥3,096.74
MX$898.20
List Price:  MX$1,257.56
You save:  MX$359.35
QR182.14
List Price:  QR255.01
You save:  QR72.87
P660.05
List Price:  P924.12
You save:  P264.07
KSh6,443.71
List Price:  KSh9,021.71
You save:  KSh2,578
E£2,369.56
List Price:  E£3,317.57
You save:  E£948.01
ብር7,778.43
List Price:  ብር10,890.43
You save:  ብር3,111.99
Kz45,607.28
List Price:  Kz63,853.85
You save:  Kz18,246.56
CLP$45,707.35
List Price:  CLP$63,993.95
You save:  CLP$18,286.60
CN¥352.01
List Price:  CN¥492.84
You save:  CN¥140.83
RD$3,174.56
List Price:  RD$4,444.65
You save:  RD$1,270.08
DA6,479.50
List Price:  DA9,071.82
You save:  DA2,592.32
FJ$112.66
List Price:  FJ$157.74
You save:  FJ$45.07
Q382.83
List Price:  Q536
You save:  Q153.16
GY$10,455.70
List Price:  GY$14,638.82
You save:  GY$4,183.11
ISK kr6,301.73
List Price:  ISK kr8,822.93
You save:  ISK kr2,521.20
DH458.73
List Price:  DH642.26
You save:  DH183.52
L841.87
List Price:  L1,178.68
You save:  L336.81
ден2,617.77
List Price:  ден3,665.09
You save:  ден1,047.32
MOP$400.62
List Price:  MOP$560.91
You save:  MOP$160.28
N$838.51
List Price:  N$1,173.99
You save:  N$335.47
C$1,839.31
List Price:  C$2,575.18
You save:  C$735.87
रु7,252.24
List Price:  रु10,153.72
You save:  रु2,901.48
S/168.29
List Price:  S/235.62
You save:  S/67.33
K212.38
List Price:  K297.36
You save:  K84.97
SAR187.52
List Price:  SAR262.55
You save:  SAR75.02
ZK1,158.20
List Price:  ZK1,621.58
You save:  ZK463.37
L216.50
List Price:  L303.11
You save:  L86.61
Kč1,034.66
List Price:  Kč1,448.60
You save:  Kč413.94
Ft16,368.18
List Price:  Ft22,916.77
You save:  Ft6,548.58
SEK kr464.96
List Price:  SEK kr650.99
You save:  SEK kr186.02
ARS$71,899.03
List Price:  ARS$100,664.40
You save:  ARS$28,765.36
Bs346.59
List Price:  Bs485.26
You save:  Bs138.66
COP$189,678.03
List Price:  COP$265,564.41
You save:  COP$75,886.38
₡24,999.25
List Price:  ₡35,000.95
You save:  ₡10,001.70
L1,316.40
List Price:  L1,843.07
You save:  L526.66
₲335,662.32
List Price:  ₲469,954.11
You save:  ₲134,291.78
$U1,955.72
List Price:  $U2,738.16
You save:  $U782.44
zł179.59
List Price:  zł251.44
You save:  zł71.85
Already have an account? Log In

Transcript

Now we have a binary number saved in our line marker array. But to retrieve the number from the letters array, we need the index number as a decimal value. In order to do that, we'll write a function that converts binary to decimal, and we'll call it bin convert. Each index of the five element array corresponds to a column of the five bit binary number we saved. And each column of a binary number has a different value. Two to the power of zero is one, two to the power of one is to two to the power of two is four, two to the power of three, eight, and two to the power of four is 16.

We'll multiply each column by the corresponding power of two and then add the results. A number will only be added if the sensor reads One in that index position. If the sensor reads zero, the number will be multiplied with zero and thus remains zero. This function will return the converted decimal number. And we'll use that number to retrieve the corresponding letter in that index in the letters array.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.