Click here to Skip to main content
15,913,090 members
Home / Discussions / C#
   

C#

 
AnswerRe: Shift operator Pin
Luc Pattyn18-Dec-09 5:09
sitebuilderLuc Pattyn18-Dec-09 5:09 
Hi,

you probably are confusing two things:

1.
assuming b is unsigned or positive, b<<24 is an attempt to generate a larger number, in fact it is equivalent to a multiplication by 2^24 (which might overflow, i.e. loose bits shifted out at the high end, and therefore could result in zero). Anyway, it is a numeric or mathematical operation. So is 5>>24 which will result in zero since all bits get lost at the low end, as others have said already.

2.
multi-byte variables (such as int) are stored in memory in one of two ways:
"big endian" = the most significant byte comes first (i.e. at the lowest address)
"little endian" = the least significant byte comes first.
Intel processors (and some others too) implement the little-endian convention. Other processor families, and some networks and protocols use big-endian (e.g. the administrative information used on Ehternet networks).


Both issues are unrelated. If you want to operate on values/numbers, look at (1). If you want to operate on memory bytes, don't look at (1), use the BitConverter class instead (or a fake "union" construction, with a struct and explicit offsets).

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


modified on Friday, December 18, 2009 11:44 AM

AnswerRe: Shift operator Pin
thungphan18-Dec-09 17:05
thungphan18-Dec-09 17:05 
GeneralRe: Shift operator Pin
harold aptroot19-Dec-09 3:29
harold aptroot19-Dec-09 3:29 
QuestionTwo ListViews Pin
Tagamoga18-Dec-09 2:38
Tagamoga18-Dec-09 2:38 
AnswerRe: Two ListViews Pin
benjymous18-Dec-09 3:14
benjymous18-Dec-09 3:14 
GeneralRe: Two ListViews Pin
Tagamoga18-Dec-09 3:29
Tagamoga18-Dec-09 3:29 
Questionzedgraph Pin
jashimu18-Dec-09 2:16
jashimu18-Dec-09 2:16 
AnswerMessage Closed Pin
18-Dec-09 2:50
stancrm18-Dec-09 2:50 
GeneralRe: zedgraph Pin
jashimu18-Dec-09 4:09
jashimu18-Dec-09 4:09 
QuestionHide database file from user Pin
NarendraSinghJTV18-Dec-09 1:53
NarendraSinghJTV18-Dec-09 1:53 
AnswerRe: Hide database file from user Pin
Ashfield18-Dec-09 2:02
Ashfield18-Dec-09 2:02 
GeneralRe: Hide database file from user Pin
NarendraSinghJTV18-Dec-09 2:33
NarendraSinghJTV18-Dec-09 2:33 
GeneralRe: Hide database file from user Pin
Saksida Bojan18-Dec-09 3:57
Saksida Bojan18-Dec-09 3:57 
GeneralRe: Hide database file from user Pin
NarendraSinghJTV18-Dec-09 17:51
NarendraSinghJTV18-Dec-09 17:51 
GeneralRe: Hide database file from user Pin
Saksida Bojan18-Dec-09 20:42
Saksida Bojan18-Dec-09 20:42 
GeneralRe: Hide database file from user Pin
Ashfield18-Dec-09 8:53
Ashfield18-Dec-09 8:53 
GeneralRe: Hide database file from user Pin
NarendraSinghJTV18-Dec-09 17:50
NarendraSinghJTV18-Dec-09 17:50 
GeneralRe: Hide database file from user Pin
Ashfield18-Dec-09 20:25
Ashfield18-Dec-09 20:25 
GeneralRe: Hide database file from user Pin
NarendraSinghJTV19-Dec-09 0:23
NarendraSinghJTV19-Dec-09 0:23 
QuestionHow to Find the documentation oF MSPastry Library in MSDN? Pin
ksaw12318-Dec-09 0:24
ksaw12318-Dec-09 0:24 
AnswerRe: How to Find the documentation oF MSPastry Library in MSDN? Pin
Dave Kreskowiak18-Dec-09 4:10
mveDave Kreskowiak18-Dec-09 4:10 
QuestionThreading Question Pin
Harvey Saayman17-Dec-09 23:11
Harvey Saayman17-Dec-09 23:11 
AnswerRe: Threading Question Pin
#realJSOP17-Dec-09 23:40
professional#realJSOP17-Dec-09 23:40 
GeneralRe: Threading Question Pin
Harvey Saayman18-Dec-09 0:24
Harvey Saayman18-Dec-09 0:24 
AnswerRe: Threading Question Pin
Pete O'Hanlon18-Dec-09 0:14
mvePete O'Hanlon18-Dec-09 0:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.