#hyper optimised telemetry:

10 messages · Page 1 of 1 (latest)

vivid scarab
#
  • hi can someone help me with the negative integer conversion to bytes array? something to do with two's compliment.. i have no background in this area, having been an office automation programer all the time. the bitconverter.getbytes does not seem to cut it.
granite gorge
#

What do you expect you to get? What are you getting? There's multiple ways to represent negatives in binary.

vivid scarab
#

the number to be converted to a byte array is Int16.Minvalue - 1.
after replacing the element at [0] with 252 (256 - size of Int16) the expected
value is [252, 255, 127, 255, 255, ...]

what i get is [252, 1, 128, 0, 0, ...]

i am using the BitConverter.GetBytes on the number.

#

what i would like to know are the steps by which the number gets converted to the expected result..

granite gorge
#

What language?

#

There's ones complement and twos complement

vivid scarab
#

sorry i was away. c#.

granite gorge
vivid scarab
#

i checked internet and was told that the bitconverter returns a valid two''s compliment array of bytes. but the exercise does not seem to think so. obviously i am doing something wrong in between. can't figure out what.. will go thru your link. thanks issac.