Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does ~ do?

 
Kendall Ponder
Ranch Hand
Posts: 205
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't in the book but it is on an enthuware test. I googled and couldn't find the answer.
 
Guillermo Ishi
Ranch Hand
Posts: 789
C++ Linux Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is called a tilde, to help you google it. It is the bitwise not operator

a = 0b010;
b = ~a;
b == 0b101;
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the unary bitwise complement operator "~". That makes googling a lot easier

It inverts a bit pattern; it can be applied to any of the integral types (not on booleans), making every "0" a "1" and every "1" a "0".

Nice to know: bit-twiddling operators are not on the OCA exam.

Hope it helps!
Kind regards,
Roel
 
Kendall Ponder
Ranch Hand
Posts: 205
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
Junilu Lacar
Bartender
Pie
Posts: 8891
81
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
 
Kendall Ponder
Ranch Hand
Posts: 205
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic