getch() unbuffered input
getchar() buffered input
getch() is not avialiable with all compilers
getchar() is avialiable with all compilers
getch() unbuffered input
getchar() buffered input
getch() is not avialiable with all compilers
getchar() is avialiable with all compilers
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 == 0Now 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 == 0Code:1111 + 1 _____ 10000
Last edited by Thantos; 05-30-2004 at 12:51 AM.
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.
what is buffered input and unbuffered input?
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)
thanks thantos