The content of this article is about the summary (code) of operations on numbers in js. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
1. Get the value of the bit-th bit in the binary form of the number num. Note:
1. Bit starts from 1
2. Returns 0 or 1
3. Example: the binary number of 2 is 10, the first bit is 0, and the second bit is 1
1 2 3 4 5 6 7 8 9 10 11 12 |
|
2. Given a binary string, convert it into the corresponding decimal number
1 2 3 |
|
3. Convert the given number into a binary string. If the string length is less than 8 digits, add 0 to the front to reach 8 digits.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
4. Find the value of multiplying a and b. A and b may be decimals. You need to pay attention to the accuracy of the result.
1 2 3 4 5 6 7 8 9 10 |
|
Related recommendations:
Summary of methods for operating arrays in js (code)
A brief analysis of the content of js event binding & event listening & event delegationThe above is the detailed content of Summary of operations on numbers in js (code). For more information, please follow other related articles on the PHP Chinese website!