473,326 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Algorithm for sbyte?

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
Jun 27 '08 #1
1 2185

"Rich" <Ri**@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.com...
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
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nick | last post by:
Hi, Problem statement: Calling a java method from Dot Net code that returns a java byte array. Overview: I have a java server from which I need to establish connection. I hva ebeen able to...
3
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example...
3
by: Steve - DND | last post by:
After downloading and using two different memory profiling applications today, it seems that sbyte, int16, and int32 are all stored using 12b of memory. Someone please tell me I'm reading these...
2
by: Ray Ackley | last post by:
I need to convert a byte to an sbyte - and it has to preserve the original binary meaning of the 8 bits. For example - a 1111 1111, which is interpreted as byte to be 255, should show up in the...
1
by: Darrel | last post by:
I am using binary writer to write an array of bytes to disk. However, my data starts out as an array of sbytes. I am currently type casting each array element in a for loop. Is there a faster...
5
by: Pat Ireland | last post by:
I am attempting to pass an SByte to another .NET class that expects the data to be passed as SByte *. I searched around and found the boxing can be used to produce a pointer but I'm not sure if...
6
by: garyusenet | last post by:
Hello i'm just starting out with csharp. and am trying to figure out why an sbyte can take any value from '-128' to 128. i've drawn a BIT box with eight bytes, and I'm assuming the eighth bit...
3
by: reju | last post by:
I have to convert an sByte array to byte array. This sbyte array contains some signed values due to this .net converting functions will throw an exception.any work around for this? is there any...
2
by: K Viltersten | last post by:
I try the following. sbyte HalvOfFour () { sbyte b = 4; return b / 2; } Apparently, since 2 is regarded as int, the operation upgrades my b to and int and after it has been performed, i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.