Learn the powerful enterprise adaptable database:

Getting Started With ADABAS & Natural

Saturday, February 3, 2018

What is Tilde in Programming?



.
This symbol (in English) informally means "approximately", "about", or "around", such as "~30 minutes before", meaning "approximately 30 minutes before".

It can mean "similar to", including "of the same order of magnitude as", such as: "x ~ y" meaning that x and y are of the same order of magnitude.

In Computer Programming such as C, Java and JavaScript,  Tilde symbol (~) represents an operator.

For example, in JavaScript, it represents a NOT Bitwise Operator.

Read the following texts for further explanation.

.
The following table summarizes JavaScript's bitwise operators:
OperatorUsageDescription
Bitwise ANDa & bReturns a 1 in each bit position for which the corresponding bits of both operands are 1's.
Bitwise ORa | bReturns a 1 in each bit position for which the corresponding bits of either or both operands are 1's.
Bitwise XORa ^ bReturns a 1 in each bit position for which the corresponding bits of either but not both operands are 1's.
Bitwise NOT~ aInverts the bits of its operand.
Left shifta << bShifts a in binary representation b (< 32) bits to the left, shifting in 0's from the right.
Sign-propagating right shifta >> bShifts a in binary representation b (< 32) bits to the right, discarding bits shifted off.
Zero-fill right shifta >>> bShifts a in binary representation b (< 32) bits to the right, discarding bits shifted off, and shifting in 0's from the left.
.

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators