The ~ (tilde) can have different meanings: it can be an operator, performing a bitwise negation on a binary number - all 1 bits are set to 0 and all 0 bits are set to 1. It can also simply be the tilde character itself, as used in Windows for shortening long path names.
Questions tagged [tilde]
171 questions
-2
votes
1 answer
Meaning of ~ in C define
I'm looking into an example application and I found this literal:
#define OFS_INIT {{(UINT16)0u},{(UINT16)~(UINT16)0u}}
void main( void )
{
LOCAL_STATIC(, RDS_UINT16, u16_msgOfs, OFS_INIT);
}
I don't have the definition of…

Federico
- 1,117
- 6
- 20
- 37
-2
votes
1 answer
Why ~ sign used before number?
I saw in many places that there some number is presenting with prefixing the ~ sign. Actually, I couldn't understand the reason why they use this special character before a number.
As an example- Every mobile PPI number is presenting with prefixing…

Eh Jewel
- 619
- 8
- 14
-2
votes
1 answer
macOS Sierra CSS general sibling combinator - weird behaviour
This snippet with 'spaces' around the tilde does not work.
h3 ~ p {
color: red;
}

Fpunkt
- 976
- 7
- 13
-3
votes
1 answer
How does the number of leading zeros in a bitwise operation (~ in Java) actually works?
I apologize if the question I’m raising is way too basic, but I really don’t understand this. And I my theoretical background is not software engineering.
Let’s say se are dealing with a Java int, which is 32 bit. So:
2 = 00000000 00000000 00000000…

LeoAlmDiniz
- 75
- 12
-3
votes
2 answers
Bitwise operators:- Ball, carrot, ampersand, tilde
I want the step by step explanation of the following code:
print(1 | 0 ^ 1 & ~0)
I tried with the output bit (output with first and second bit) and got the answer as 0. The tilde function got me hooked up for some time I found it a bit hard. The…
user20349571
-4
votes
2 answers
Why the if statement is false as ~0 is 1 which is 1==1 should be true?
#include
int main() {
if (~0 == 1)
printf("yes\n");
else
printf("no\n");
}
why is the if statement false? can anyone explain?

Gajanan
- 11
- 3