Algorithm for sbyte?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UmljaA==?=

    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.Globaliz ation.NumberSty les.HexNumber, null);

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

    Cheers,
    Rich
  • Anthony Jones

    #2
    Re: Algorithm for sbyte?


    "Rich" <Rich@discussio ns.microsoft.co mwrote in message
    news:B1C8F3CA-5182-4B56-B814-76ACB159876A@mi crosoft.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.Globaliz ation.NumberSty les.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.or g/wiki/Two's_complemen t



    --
    Anthony Jones - MVP ASP/ASP.NET


    Comment

    Working...