filmov
tv
Lecture No 56 JavaScript function to convert a binary number to a decimal number urdu/hindi

Показать описание
#javascript #developer #advance #learning #javascriptengineer #maths #advance #decimals #binary
Convert Binary to Decimal
Converting binary numbers to decimal is easy. For example, let x = '101010' creates a new variable x that contains the number as a string 101010. JavaScript has a parseInt() method that takes a binary and radix parameter, and returns a number. Calling parseInt(binary, radix) tells JavaScript to convert binary to a number containing the decimal representation of 101010. If binary is not a string, it will be converted to one using the toString() function.
No Technology Method
How do you quickly convert 101010 to 42 without a computer? It takes some practice to make it easy, but here's a few ways to convert a binary string to a decimal number. One method discussed is doubling, described below:
Take the binary string.
Starting from the left, double your previous total and add the current digit.
Double your current total and add the next leftmost digit.
Repeat the previous step until you have gone through the entire string.
Convert Binary to Decimal
Converting binary numbers to decimal is easy. For example, let x = '101010' creates a new variable x that contains the number as a string 101010. JavaScript has a parseInt() method that takes a binary and radix parameter, and returns a number. Calling parseInt(binary, radix) tells JavaScript to convert binary to a number containing the decimal representation of 101010. If binary is not a string, it will be converted to one using the toString() function.
No Technology Method
How do you quickly convert 101010 to 42 without a computer? It takes some practice to make it easy, but here's a few ways to convert a binary string to a decimal number. One method discussed is doubling, described below:
Take the binary string.
Starting from the left, double your previous total and add the current digit.
Double your current total and add the next leftmost digit.
Repeat the previous step until you have gone through the entire string.