PC Review


Reply
Thread Tools Rate Thread

Algorithm for sbyte?

 
 
Rich
Guest
Posts: n/a
 
      19th Jun 2008
Dear All,

Does anyone know the algorithm used to convert to an sbyte like follows? It
is not a straight hex conversion.

sbyte.Parse("B2", System.Globalization.NumberStyles.HexNumber, null);

Any help is appreciated. Thanks and have a great day!

Cheers,
Rich
 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      19th Jun 2008

"Rich" <(E-Mail Removed)> wrote in message
news:B1C8F3CA-5182-4B56-B814-(E-Mail Removed)...
> Dear All,
>
> Does anyone know the algorithm used to convert to an sbyte like follows?

It
> is not a straight hex conversion.
>
> sbyte.Parse("B2", System.Globalization.NumberStyles.HexNumber, null);
>


It is a straight hex conversion and ends up storing the same binary value in
the byte as it would in an unsigned byte. Its how the binary value is then
interpreted as a number. The top bit being set indicates its a negative
number in signed byte.

The algorithm is called 2's complement. See:-

http://en.wikipedia.org/wiki/Two's_complement



--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SByte vs. bool vs. TinyInt Martin Groh Microsoft C# .NET 4 4th Dec 2008 01:50 PM
sbyte understanding needed garyusenet@myway.com Microsoft C# .NET 6 25th Jan 2006 03:20 PM
byte[] <=> sbyte[] =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= Microsoft Dot NET Framework 9 12th Oct 2005 06:41 PM
covernting SByte [] to SByte * =?Utf-8?B?UGF0IElyZWxhbmQ=?= Microsoft C# .NET 5 19th Sep 2005 07:55 PM
Conversion from Stream to SByte =?Utf-8?B?Tmljaw==?= Microsoft Dot NET 2 5th Jul 2005 08:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:39 AM.