
Computer Science Computer Science Forum 
 LinkBack  Thread Tools  Display Modes 
February 24th, 2018, 12:59 AM  #1 
Member Joined: Jan 2016 From: Uk Posts: 75 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, 06:20 AM  #2 
Global Moderator Joined: Dec 2006 Posts: 18,719 Thanks: 1536 
Are the bytes individually in that form, or are they to be considered together as a single value in that form?

February 25th, 2018, 11:36 PM  #3 
Senior Member Joined: Apr 2014 From: UK Posts: 809 Thanks: 301 
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 04:21 PM 
p (B intersect (A complement))  finalight  Algebra  1  March 27th, 2012 12:34 PM 
Complement of Whole Space  lu5t  Real Analysis  3  May 31st, 2011 09:36 PM 
complement of sets  Ben92  Applied Math  1  February 7th, 2011 07:19 AM 
twos complement addition/subtraction  whizbang  Computer Science  1  January 28th, 2011 09:50 PM 