3 Replies - 3445 Views - Last Post: 31 July 2012 - 05:09 AM

#1 TechSyndrome  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 135
  • Joined: 06-May 12

Binary Arithmetic - in 8-bit addition, do I discard remaining no's

Posted 29 July 2012 - 08:25 AM

For example:

Posted Image

As you can see, I have '1' (circled in red), left over. Because my aim is to get 8-bits for a two's complement question, do I just discard this? I just want to make sure that I am doing this the correct way. Would appreciate any help on this.

This post has been edited by TechSyndrome: 29 July 2012 - 08:26 AM

Is This A Good Question/Topic? 0
  • +

Replies To: Binary Arithmetic - in 8-bit addition, do I discard remaining no's

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2153
  • View blog
  • Posts: 3,313
  • Joined: 21-June 11

Re: Binary Arithmetic - in 8-bit addition, do I discard remaining no's

Posted 29 July 2012 - 08:56 AM

Yes, when performing arithmetic on fixed-width n-bit integers, you discard any bits that carry over to the n+1st bit.

In effect this means that arithmetic with n-bit (unsigned) integers is equivalent to regular arithmetic modulo 2n.
Was This Post Helpful? 1
  • +
  • -

#3 TechSyndrome  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 135
  • Joined: 06-May 12

Re: Binary Arithmetic - in 8-bit addition, do I discard remaining no's

Posted 29 July 2012 - 08:57 AM

View Postsepp2k, on 29 July 2012 - 08:56 AM, said:

Yes, when performing arithmetic on fixed-width n-bit integers, you discard any bits that carry over to the n+1st bit.

In effect this means that arithmetic with n-bit (unsigned) integers is equivalent to regular arithmetic modulo 2n.


Thank you. Appreciate it.
Was This Post Helpful? 0
  • +
  • -

#4 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2069
  • View blog
  • Posts: 4,307
  • Joined: 11-December 07

Re: Binary Arithmetic - in 8-bit addition, do I discard remaining no's

Posted 31 July 2012 - 05:09 AM

Yup, that's right. The Z80 chip also has a carry flag which would be set in those circumstances. I assume modern processors have an equivalent.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1