This site is no longer active and is available for archival purposes only. Registration and login is disabled.

number to bitshift


number to bitshift

Postby Malmer » Oct 9, 2002 @ 5:10pm

All your base are belong to us
User avatar
Malmer
pm Member
 
Posts: 768
Joined: Apr 26, 2001 @ 5:15pm
Location: Sweden


Postby angedelamort » Oct 9, 2002 @ 5:18pm

User avatar
angedelamort
pm Member
 
Posts: 304
Joined: Mar 7, 2002 @ 11:16pm
Location: Montreal, Quebec


Postby refractor » Oct 9, 2002 @ 5:21pm

User avatar
refractor
pm Insider
 
Posts: 2304
Joined: Feb 5, 2002 @ 1:12pm
Location: Luxembourg


Postby Dave H » Oct 9, 2002 @ 5:27pm

Dave H.
Lead Programmer (Repton PPC/7650)
[url=http://www.handango.com/PlatformProductDetail.jsp?productId=43741]
Buy Repton Online here!
[/url]
User avatar
Dave H
pm Member
 
Posts: 164
Joined: Oct 3, 2002 @ 5:01pm


Postby Digby » Oct 9, 2002 @ 5:49pm

If you're running on XScale you can use CLZ, then subtract the result from 31.

Otherwise, I'd probably perform a series of AND operations with mask and use a divide-and-conquer approach to find the set bit (test HIWORD/LOWORD, test HIBYTE/LOBYTE, test HINIBBLE/LONIBBLE, etc.). This will get you the result after 5 ANDs and 5 comparisons. It's not one line of code, but it's probably faster than the other methods suggested.
Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Postby refractor » Oct 9, 2002 @ 6:08pm

User avatar
refractor
pm Insider
 
Posts: 2304
Joined: Feb 5, 2002 @ 1:12pm
Location: Luxembourg


Postby Malmer » Oct 9, 2002 @ 6:56pm

All your base are belong to us
User avatar
Malmer
pm Member
 
Posts: 768
Joined: Apr 26, 2001 @ 5:15pm
Location: Sweden


Postby Malmer » Oct 9, 2002 @ 6:59pm

All your base are belong to us
User avatar
Malmer
pm Member
 
Posts: 768
Joined: Apr 26, 2001 @ 5:15pm
Location: Sweden


Postby Guest » Oct 9, 2002 @ 7:17pm

Guest
 


Postby Malmer » Oct 9, 2002 @ 10:54pm

If it is the software will create a huge disruption in space time continuum, which will lead to the ultimate destruction of the universe and everything in it, except for the duracell bunny. It keeps going and going forever and ever...

...Or maybe not...
All your base are belong to us
User avatar
Malmer
pm Member
 
Posts: 768
Joined: Apr 26, 2001 @ 5:15pm
Location: Sweden


Postby refractor » Oct 9, 2002 @ 11:31pm

Here's another potential issue - what happens if b is negative?

As it's signed, the shift will be arithmetic, thus it'll end up as -1, never 1... giving us the infinite loop until the bunny's batteries run out ;)
User avatar
refractor
pm Insider
 
Posts: 2304
Joined: Feb 5, 2002 @ 1:12pm
Location: Luxembourg


Postby Malmer » Oct 9, 2002 @ 11:49pm

What if the bunny is connected to a 12V adaptor...then we have serious issues with the world collapsing and stuff...
All your base are belong to us
User avatar
Malmer
pm Member
 
Posts: 768
Joined: Apr 26, 2001 @ 5:15pm
Location: Sweden


Postby sponge » Oct 10, 2002 @ 2:13am

Your forgetting all about the Bunny factor D, which states that to sucessfully power a bunny, you will need a cold fusion reactor, so keeping the bunny powered after the break is merely a dream.
holy internets batman.
User avatar
sponge
Not sponge
 
Posts: 12779
Joined: Jan 13, 2002 @ 8:04am
Location: New Hampshire


Postby Malmer » Oct 10, 2002 @ 2:46pm

Ouch forgot that...so the problem will basically cause the entire universe to collapse, and that's it...?

maybe I should run my app in debug mode first, so I can catch the exception before the world is destroyed.
All your base are belong to us
User avatar
Malmer
pm Member
 
Posts: 768
Joined: Apr 26, 2001 @ 5:15pm
Location: Sweden


Postby Dan East » Apr 12, 2003 @ 3:48am

Has anyone tried the code Refractor posted? I can't get it to return proper results.

Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Next

Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum