0

what is ~ operator? and why + - is in top of precedence after exponentiation? :/

11th Sep 2016, 7:01 AM
Mohammad Ghaznavi
Mohammad Ghaznavi - avatar
3 ответов
+ 2
operators are used to perform math operation....such as addition, subtraction, division etc -+ are on top maybe because they are simplest and always come first.
19th Sep 2016, 8:18 AM
Terry Jephtah Shemishere
Terry Jephtah Shemishere - avatar
0
~ is the complementary operator we have the one's complement and two's complement.it depends on wat version your Python uses,two complement is very useful because it enables us represent both positive and negative numbers in signed binary notation,where the msb(most significant bit) is used as the sign bit,a 1 means negative and a 0 positive,to get the negative bit representation of unsigned number we find the two complement of that unsigned number,eg unsigned 7 is 00000111 in binary(I.e a byte) while -7 in signed notation is 11111001,hw did I get it u ask? ok let work it out first we find the one's complement by inverting all the bits in 7 i.e 00000111 => 11111000 that it we just did the one's complement of 7 to do the two complement we simply add 1 to the one complement 00000111 11111000 (one's complement) +1 11111001 (two's complement) + is the unary plus to make a number positive - is the unary minus to make a number negative
9th Jan 2017, 11:05 PM
Ayaah Silas
0
they are at the top because they have to be executed first, before any operator lower than it because it formats the number to the corresponding sign or binary notation desired before it is used by other operators
9th Jan 2017, 11:12 PM
Ayaah Silas