The docs say that ! is "Boolean not. Implements three-valued logic" and ~ is "Bitwise not."
When should one be used versus the other?
There is a similar question for Python about comparison operators, but I am not sure where the languages may differ.