Binary digits: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: Added a variation) |
|||
Line 1,825: | Line 1,825: | ||
<lang dyalect>func Integer.toString() { |
<lang dyalect>func Integer.toString() { |
||
var s = "" |
var s = "" |
||
for x in 31..0 { |
for x in 31^-1..0 { |
||
if this & (1 << x) != 0 { |
if this &&& (1 <<< x) != 0 { |
||
s += "1" |
s += "1" |
||
} else if s != "" { |
} else if s != "" { |
||
Line 1,834: | Line 1,834: | ||
s |
s |
||
} |
} |
||
print("5 == \(5), 50 = \(50), 1000 = \(9000)")</lang> |
print("5 == \(5), 50 = \(50), 1000 = \(9000)")</lang> |
||