in reply to Re: reliable get position of leftmost bit in large integers
in thread reliable get position of leftmost bit in large integers

No, because the problem triggers on vectors filled with on-bits. But the exponentiation ** also seems to have a problem (thanks your remark):

$ perl -e 'print sprintf("%b",2**53-1),"\n"' 11111111111111111111111111111111111111111111111111111 $ perl -e 'print sprintf("%b",2**54-1),"\n"' 1000000000000000000000000000000000000000000000000000000 $ perl -e 'print sprintf("%b",2**(53-1)),"\n"' 10000000000000000000000000000000000000000000000000000

Replies are listed 'Best First'.
Re^3: reliable get position of leftmost bit in large integers
by Eily (Monsignor) on Mar 12, 2015 at 13:09 UTC

    The problem is that ** returns a double (floating point), which explains the lack of precision. You should use 1<<54 like BrowserUk did in his answer.

      You should use 1<<54 like BrowserUk did in his answer.

      Even old dogs can learn :)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked