aspose file tools
The moose likes Java in General and the fly likes fastest way to access certain digit in long Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "fastest way to access certain digit in long" Watch "fastest way to access certain digit in long" New topic
Author

fastest way to access certain digit in long

Hendra Kurniawan
Ranch Hand

Joined: Jan 31, 2011
Posts: 239
lets say I have :


and I want to get the fourth digit from behind (in this case, the number would be 7). What's the fastest way to get this number? Is there any faster way than this?

Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2816
    
    2
I think that's the fastest way, right there.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 4901
    
    7

Hendra Kurniawan wrote:Is there any faster way than this?

Not unless you want to get really geeky

And I'd advise strongly against it.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
It is much quicker if you want to access the i-th bit, or a digit in hexadecimal, which you can do with the << & and >> operators.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: fastest way to access certain digit in long
 
Similar Threads
Quickest way to read in a Web page
Sum Of Digits
Packed decimal conversion - Java
substring to just get the last character
multiples project (three five) project euler