in reply to Re: Range iterator outside integer range ... Why?
in thread Range iterator outside integer range ... Why?

So, if I'm interpreting your (rather terse) message correctly, because 2**63 is greater than a signed 64-bit int, it gets coersed into a double; before the subtraction is done.

And because 63-bits of precision is greater than the 53 bits the double can retain, by the time the subtraction is done, the loss of precision causes the problem.

In anycase, 1<<63-1 is a much nicer way of writing that constant. Thanks!


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".
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
  • Comment on Re^2: Range iterator outside integer range ... Why?

Replies are listed 'Best First'.
Re^3: Range iterator outside integer range ... Why?
by Eily (Monsignor) on Jan 16, 2015 at 16:27 UTC

    Or, as stated by oiskuu here, it's because 2**63 is implemented with pow, when 1<<63 actually works on integers.