Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
    Bookmark Topic Watch Topic
  • New Topic

Bit Scan Forward in java

 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Report post to moderator
how can we implement BSF(Bit Scan Forward) assembly code in java in the most efficient way.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Report post to moderator
If you've got Jdk 5 or later, check out Integer.numberOfLeadingZeros() and Integer.numberOfTrailingZeros(). Or the same methods in class Long. Otherwise, you have to write a loop to do it with bitshifting and a bitmask. Do you have an application with a real need for this, or is it a homework problem?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Vikas' question is about a chess program, see this topic in the Game Development forum: Java Chess Game I made by my self
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hm, well since the original post has a lot more useful context, I think I'll close this thread and follow up there instead.
 
    Bookmark Topic Watch Topic
  • New Topic