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

Bit Shift


Bit Shift

Postby brendan » Feb 7, 2002 @ 1:53am

Howdy, just wondering whats the easyest way to shift a high byte into the low byte..

Eg, I've a mutli-d array of numbers (signed short).. 256,512,768,1024... etc, and I want to convert them to 1,2,3,4 etc. (there is no low byte info etc)

sample code
//source is 256,512 (high byte) etc
// converted to 1, 2 etc....

level.fg_data[loop1][loop2] = level1_data[loop1][loop2];

-thanks
User avatar
brendan
pm Insider
 
Posts: 451
Joined: Oct 23, 2001 @ 2:51am
Location: Hobart, Australia


Postby brendan » Feb 7, 2002 @ 5:21am

User avatar
brendan
pm Insider
 
Posts: 451
Joined: Oct 23, 2001 @ 2:51am
Location: Hobart, Australia


Postby Dan East » Feb 7, 2002 @ 5:45am

level.fg_data[loop1][loop2] >>= 8;

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


Postby brendan » Feb 7, 2002 @ 6:18am

thankyou :)
User avatar
brendan
pm Insider
 
Posts: 451
Joined: Oct 23, 2001 @ 2:51am
Location: Hobart, Australia


Postby refractor » Feb 7, 2002 @ 12:05pm

You may not want to be using the signed short (depending on what you're doing with the data)... think about using an unsigned short instead maybe.

If the data-type is signed then (IIRC), the C/C++ compiler will use *arithmetic* shifts, not *logical* shifts. This probably isn't what you want for data like bitmaps.

Cheers,

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


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

cron