This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fastest way to access certain digit in long

 
Hendra Kurniawan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3028
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that's the fastest way, right there.
 
Winston Gutkowski
Bartender
Pie
Posts: 10109
56
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Campbell Ritchie
Sheriff
Posts: 48404
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic