<Br/> alert (parseint ("101101", 2) <br/>
RunCode
<Br/> function Tobin (intnum) {<br/> var answer = ""; <br/> If (/\ D + /. test (intnum) {<br/> while (intnum! = 0) {<br/> answer = math. ABS (intnum % 2) + answer; <br/> intnum = parseint (intnum/2); <br/>}< br/> If (answer. length = 0) <br/> answer = "0"; <br/> return answer; <br/>} else {<br/> return 0; <br/>}< br/> alert (Tobin (45) <br/>
Run code
<Br/> function Tobin (DEC) {<br/> var bits = []; <br/> var dividend = Dec; <br/> var remainder = 0; <br/> while (dividend> = 2) {<br/> remainder = dividend % 2; <br/> bits. push (remainder); <br/> dividend = (dividend-remainder)/2; <br/>}< br/> bits. push (dividend); <br/> bits. reverse (); <br/> return bits. join (""); <br/>}< br/> alert (Tobin (45) <br/>
Run code
Alert (2 .. tostring (2) // if an error occurs at a certain point, the engine cannot determine whether it is a decimal point or ". "operator, or here a" shift-shift confilt "alert (2.0.tostring (2) Alert (2) is generated ). tostring (2 ))
The word "shift-shift confilt" comes from the compilation principle. I directly read the e-version at the time. I don't know how to translate it. It roughly means that during lalr syntax analysis, when you need to execute the action of popping up a token from the input sequence and pushing it into the syntax stack, this token has two or more different semantics.
Correspondingly, syntax analysis usually has two actions: Shift and reduce. In LR (1), shift-Reduce conflit is acceptable, but shift-shift conflit is not acceptable.
This is roughly the meaning.
0 0 0 1 0 0 0 // the first digit is 3rd, which is 2 ^ (3-1) = 4 if the first 1st digits of 1 are 5th bits, then 2 ^ (5-1) = 16 is used in combination with 4 + 16 = 20.