question

This is a discussion on question within the C++ Programming forums, part of the General Programming Boards category; why is 11111111+1 + to -1?...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    28

    question

    why is 11111111+1 + to -1?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,255
    Is there a typo in that question? I dont understand what you are asking.

  3. #3
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    You mean binary or decimal or what...

    If binary then all I can figure is that when the left most bit of a signed variable is 1 that means its negitive. Thats why and unsigned char can hold 0-255 and a signed char like -127 to 127 ( er something like that )
    What is C++?

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >why is 11111111+1 + to -1?
    Whether this is true depends on what universe you're from. Would you care to be more specific please?
    My best code is written with the delete key.

  5. #5
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    well i think he is using some old 16 bit dos compilers... when he does 11111111+1 the limit of the variable is reached and the bit pattern is read as -1.....

  6. #6
    Registered User
    Join Date
    Oct 2004
    Posts
    30
    i agree with vicious

    this is binary arithmetic as i suppose
    it is like this

    11111111 + 1 = 100000001

    since in binary most significant bit represents a sign
    it gets set to 1 and read as
    1------------->for sign ---->i.e.-ve
    00000001----->read as 1
    combine it as -1

    i hope u understood
    and anybody correct me if i am wrong
    been a long time since binary arithmetic
    Syra
    Amateur's urge to master C/C++

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 03:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 06:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 01:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21