Hacker News new | ask | show | jobs
by dan-robertson 2004 days ago
In Java (I think that is the implementation language,) longs are 64bit and ints are 32bit, so I think this problem doesn’t come up
2 comments

It did at one point, I recall Sun had that exact bug at some point back around 1.4, I remember it being fixed. Of course the long conversions alleviate the problem but at a performance cost and its an avoidable cast.
No java doesn't use 64bits at all. It uses unsigned right shift. I mentioned it in another post: "int mid = (low + high) >>> 1;"... And for the older timers (14y ago), there used to be a bug[0] about exactly that.

[0] https://bugs.openjdk.java.net/browse/JDK-5045582