Path: utzoo!utgpu!water!watmath!clyde!rutgers!princeton!udel!gatech!hubcap!ncrcae!ncr-sd!hp-sdd!hplabs!hpcea!hpcilzb!tedj From: tedj@hpcilzb.HP.COM (Ted Johnson) Newsgroups: comp.lang.c Subject: Simple question about: ~ Message-ID: <1620006@hpcilzb.HP.COM> Date: 25 Jan 88 07:27:03 GMT Organization: HP Design Tech Center - Santa Clara, CA Lines: 33 Could someone please explain why the following statements both give the same answer? short int x, y = 12; x = -y -1; vs. short int x, y = 12; x = ~y; Both ways end up assigning x the value of -13. K&R say something about the ~ operator taking the one's complement of a number, but I didn't follow their explanation... The only reason I ask is because I saw two different programs compute the same function in two different ways, and I want to know if they are really doing the same thing or if this is a special case where both functions give the same answer. Thanks in advance! -Ted P.S. This was on a machine where a short int is 16 bits.