What is the “~” symbol used for? - Letsdiskuss
LetsDiskuss Logo
Ask Question


Updated 16 Jan, 2020 |

What is the “~” symbol used for?

Chhavi Tyagi

digital marketer | Posted 17 Jan, 2020

In Computer Programming language, tilde(~) is called bitwise supplement operator.

Permit say, x is an Integer.

So, the cost of ~x can be -x-1.

Example :
1.) if x = 10 then
~x = -eleven;

2.) if x = 0 then
~x = -1;

3.) if x = -10 then
~x = 9;

Explanation :
while x = 10, then its binary representation could be 0000 1010 and now if we compute the cost of ~x(by way of inverting all of the bits) , we will get binary representation 1111 0101 which is now equal to -eleven

This has happened because inverting all of the bits will always trade the sign of an integer.

That’s why we usually gets the value of ~x through complementing all of the bits and subtracting 1 from it.

Why Subtracting 1 ?? As we all understand terrible of a variety of is received via complementing that quantity and adding 1 to that quantity.

In Maths,I knew the symbol “~” is known as as tilde & used for approximation in Mathematics.

In Spanish, it is used handiest on pinnacle of an N to provide a new letter, Ñ, which has a new sound.

In Portuguese , it modifications the way A and O are pronounced, àand Õ, nevertheless the ones sounds however with a more nasal sound.

Hope this may assist you.