A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Head First Android
this week in the
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?
Articles by Winston can be found
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.
It is sorta covered in the
JavaRanch Style Guide
subject: fastest way to access certain digit in long
Quickest way to read in a Web page
substring to just get the last character
multiples project (three five) project euler
Packed decimal conversion - Java
Sum Of Digits
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015