jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Bit Scan Forward in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

Bit Scan Forward in java

vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
how can we implement BSF(Bit Scan Forward) assembly code in java in the most efficient way.
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
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?

"I'm not back." - Bill Harding, Twister
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14956

Vikas' question is about a chess program, see this topic in the Game Development forum: Java Chess Game I made by my self

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
Hm, well since the original post has a lot more useful context, I think I'll close this thread and follow up there instead.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Bit Scan Forward in java
It's not a secret anymore!