Find first and last set bit of a long integer: Difference between revisions
Content added Content deleted
(Find first and last set bit of a long integer en BASIC256) |
(→{{header|Wren}}: Now uses new core library method.) |
||
Line 1,812: | Line 1,812: | ||
{{libheader|Wren-big}} |
{{libheader|Wren-big}} |
||
{{libheader|Wren-fmt}} |
{{libheader|Wren-fmt}} |
||
{{libheader|Wren-math}} |
|||
<lang ecmascript>import "/big" for BigInt |
<lang ecmascript>import "/big" for BigInt |
||
import "/fmt" for Fmt |
import "/fmt" for Fmt |
||
import "/math" for Math |
|||
var rupb = Fn.new { |x| (x is BigInt) ? x.bitLength - 1 : |
var rupb = Fn.new { |x| (x is BigInt) ? x.bitLength - 1 : x.log2.floor } |
||
var rlwb = Fn.new { |x| rupb.call(x & -x) } |
var rlwb = Fn.new { |x| rupb.call(x & -x) } |
||
Line 1,853: | Line 1,851: | ||
1302^6 = 4,871,535,877,925,849,664 rupb: 62 rlwb: 6 |
1302^6 = 4,871,535,877,925,849,664 rupb: 62 rlwb: 6 |
||
</pre> |
</pre> |
||
=={{header|Yabasic}}== |
=={{header|Yabasic}}== |