Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Tilde
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=====Negation===== In [[APL (programming language)|APL]]<ref name="j303">{{cite web |title=APL2 Programming: Language Reference |publisher=[[IBM]] |url=https://www.ibm.com/downloads/cas/ZOKMYKOY |date=February 1994 |edition=2nd |access-date=2024-10-22}}</ref>{{rp|68}} and [[MATLAB]],<ref>{{cite web |title=MATLAB Operators and Special Characters - MATLAB & Simulink |website=MathWorks |url=https://www.mathworks.com/help/matlab/matlab_prog/matlab-operators-and-special-characters.html |access-date=2024-10-22}}</ref> tilde represents the monadic logical function NOT. and in APL it additionally represents the dyadic [[multiset]] function ''without'' ([[Complement (set theory)#Relative complement|set difference]]).<ref name="j303"/>{{rp|258}} In [[C (programming language)|C]] the tilde character is used as [[bitwise NOT]] unary [[Operators in C and C++|operator]], following the notation in logic (an <code>!</code> causes a logical NOT, instead).<ref>{{cite web |title=Programming languages β C |url=https://files.lhmouse.com/standards/ISO%20C%20N2176.pdf |author=ISO/IEC |access-date=2024-10-19 |page=64 }}</ref> This is also used by many languages based on or influenced by C, such as [[C++]], [[C Sharp (programming language)|C#]], [[D programming language|D]], [[Java (programming language)|Java]], [[JavaScript]], [[Perl]], [[PHP]], and [[Python (programming language)|Python]].<ref name="rigaux">{{Cite web |title=syntax across languages (One Big Page) |url=https://rigaux.org/language-study/syntax-across-languages.html |access-date=2024-11-28 |website=rigaux.org |archive-url=https://web.archive.org/web/20240823220158/http://rigaux.org/language-study/syntax-across-languages.html |archive-date=2024-08-23}}</ref> The [[MySQL|MySQL database]] also use tilde as bitwise invert<ref>{{Cite web|url=https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-invert|title=MySQL :: Reference Manual :: Bit Functions and Operators|website=dev.mysql.com|access-date=2019-12-20}}</ref> as does Microsoft's SQL Server [[Transact-SQL|Transact-SQL (T-SQL)]] language. ======~~ cast====== <!-- This section title is linked to, so if you change the section title then please place this anchor in the page text here: {{anchor|~~ cast}} --> [[JavaScript]] also uses tilde as bitwise NOT. Because bitwise operators work on integers, and numbers in JavaScript are 64 bit floating point numbers, the operator converts numbers to a 32-bit signed integer before it performing the negation.<ref>{{Cite web |title=JavaScript Bitwise Operations |url=https://www.w3schools.com/js/js_bitwise.asp |access-date=2024-11-28 |website=W3Schools |language=en-US |archive-url=https://web.archive.org/web/20241128173553/https://www.w3schools.com/js/js_bitwise.asp |archive-date=2024-11-28}}</ref> The conversion truncates the fractional part and most significant bits. This lets two tildes <code>~~x</code> to be used as a short syntax to cast to integer. However, it is not recommended as use for truncation. In contrast, it does not truncate BigInts, which are arbitrarily large integers.<ref>{{Cite web |date=2023-08-15 |title=Bitwise NOT (~) - JavaScript |url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_NOT |access-date=2024-11-28 |website=MDN |language=en-US |archive-url=https://web.archive.org/web/20241128173342/https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_NOT |archive-date=2024-11-28}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)