Find first and last set bit of a long integer: Difference between revisions

added Arturo
(Added Forth entry)
(added Arturo)
Line 302:
18227236413148063624904752885045248| 11 |113 |111000001010101100000100010100010101100000011011010011001110101111101110010001100000011001010001101001100000000000
</pre>
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="arturo">msb: function [x]-> dec size as.binary x
lsb: function [x]-> msb and x neg x
 
loop 0..5 'i [
x: 42 ^ i
print [pad to :string x 10 "-->" "MSB:" pad.right to :string (msb x) 2 "- LSB:" lsb x]
]
 
print ""
 
loop 0..5 'i [
x: 1302 ^ i
print [pad to :string x 17 "-->" "MSB:" pad.right to :string (msb x) 2 "- LSB:" lsb x]
]</syntaxhighlight>
 
{{out}}
 
<pre> 1 --> MSB: 0 - LSB: 0
42 --> MSB: 5 - LSB: 1
1764 --> MSB: 10 - LSB: 2
74088 --> MSB: 16 - LSB: 3
3111696 --> MSB: 21 - LSB: 4
130691232 --> MSB: 26 - LSB: 5
 
1 --> MSB: 0 - LSB: 0
1302 --> MSB: 10 - LSB: 1
1695204 --> MSB: 20 - LSB: 2
2207155608 --> MSB: 31 - LSB: 3
2873716601616 --> MSB: 41 - LSB: 4
3741579015304032 --> MSB: 51 - LSB: 5</pre>
 
=={{header|AutoHotkey}}==
Line 326 ⟶ 359:
42^10 --> First : 10 , Last : 53
42^11 --> First : 11 , Last : 59</pre>
 
 
=={{header|BASIC256}}==
1,532

edits