A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
fastest way to access certain digit in long
Joined: Jan 31, 2011
Jun 01, 2012 22:32:57
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?
Joined: Mar 05, 2008
Jun 01, 2012 22:44:39
I think that's the fastest way, right there.
Joined: Mar 17, 2011
Jun 02, 2012 04:42:59
Hendra Kurniawan wrote:
Is there any faster way than this?
Not unless you want to get
And I'd advise strongly against it.
Isn't it funny how there's always time and money enough to do it WRONG?
Joined: Oct 13, 2005
Jun 02, 2012 05:59:05
It is much quicker if you want to access the
-th bit, or a digit in hexadecimal, which you can do with the << & and >> operators.
I agree. Here's the link:
subject: fastest way to access certain digit in long
multiples project (three five) project euler
substring to just get the last character
Packed decimal conversion - Java
Sum Of Digits
Quickest way to read in a Web page
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013