
Computer Science Computer Science Forum 
 LinkBack  Thread Tools  Display Modes 
February 24th, 2018, 01:59 AM  #1 
Member Joined: Jan 2016 From: Uk Posts: 93 Thanks: 2  Twos complement on a computer
Hi, I am making a PCB project using a Compass module, and a computer program. I am now getting results, of 2x BYTEs HB and LB. The data sheet explains that the two bytes are in 'twos complement' form. I now need to program the result from these two BYTEs. If anyone has maths and computer skills, would they they let me know how to do this please? Thanks, Camerart. 
February 24th, 2018, 07:20 AM  #2 
Global Moderator Joined: Dec 2006 Posts: 19,951 Thanks: 1842 
Are the bytes individually in that form, or are they to be considered together as a single value in that form?

February 26th, 2018, 12:36 AM  #3 
Senior Member Joined: Apr 2014 From: UK Posts: 892 Thanks: 328 
It depends what you want the result to look like. If you just want a positive number between 0 and 65535, just add 32768, assuming the 2 bytes are a single number. What module is it? 

Tags 
complement, compliment, computer, twos 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Two's complement: Am I on the right track here?  Horizyn  Computer Science  3  December 31st, 2014 05:21 PM 
p (B intersect (A complement))  finalight  Algebra  1  March 27th, 2012 01:34 PM 
Complement of Whole Space  lu5t  Real Analysis  3  May 31st, 2011 10:36 PM 
complement of sets  Ben92  Applied Math  1  February 7th, 2011 08:19 AM 
twos complement addition/subtraction  whizbang  Computer Science  1  January 28th, 2011 10:50 PM 