Thread: unsigned char & signed char

  1. #16
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    getch() unbuffered input
    getchar() buffered input

    getch() is not avialiable with all compilers
    getchar() is avialiable with all compilers

  2. #17
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Ones complement = invert all the bits
    Twos complement = adding 1 to the ones complement

    http://www.drtak.org/teaches/ARC/cis...ok/node62.html

    Example: -1's big representation in binary.
    (using 4 bits)
    1) look at the sign, its negitive so we know we'll have to use two's complement.
    2) Get binary value of |-1| which is 0001
    3) Take ones complement: 1110
    4) add one to get twos complement 1110 + 1 = 1111

    there you have it

    proof: -1 to 1 == 0
    Code:
     1111
    +   1
    _____
    10000
    Now there is a rule when dealing with binary numbers. You always take the least signifiant bits. In this case we are only looking at 4 bits so the 1 gets thrown away and we are left with 0000 == 0
    Last edited by Thantos; 05-30-2004 at 12:51 AM.

  3. #18
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    not quite.

    1110 is the ones complement of 1

    Negitive numbers can not be held in binary (there is no negitive / positive sign). As such the system of two's complement was developed.

    Read the links, they explain a lot
    Last edited by Thantos; 05-30-2004 at 01:51 AM.

  4. #19
    Registered User
    Join Date
    May 2004
    Posts
    70
    what is buffered input and unbuffered input?

  5. #20
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    in the basic terms:
    buffered input : the input is buffered by the operating system and is sent to the program once the enter key is pressed

    unbuffered input : the input is sent to program as they are inputted.

    also sometimes refered to as cook (buffered) vs raw (unbuffered)

  6. #21
    Registered User
    Join Date
    May 2004
    Posts
    70
    thanks thantos

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. A Question About Unit Testing
    By Tonto in forum C++ Programming
    Replies: 2
    Last Post: 12-14-2006, 08:22 PM
  3. Replies: 7
    Last Post: 06-16-2006, 09:23 PM
  4. convert maybe maybe not..
    By pico in forum C Programming
    Replies: 7
    Last Post: 03-15-2005, 10:13 AM
  5. ANY BODY WILLING TO HELP ME WITH Microsoft Visual C++
    By BiG pImPiN fOoL in forum C++ Programming
    Replies: 12
    Last Post: 11-04-2001, 06:03 PM