That key left of ‘1’ on many keyboards is actually crucial for programmers

image

The humble tilde has many uses.

The humble tilde (~) symbol, which is located left of the “1” key, has a few notable uses. It can represent approximations, which is useful in mathematics and statistics, and is found as an accent over letters in languages like Spanish and Portuguese. You’ve probably spent some time hunting for it on a keyboard when spelling stuff like “mañana.” However, its primary use on a computer keyboard is as a tool in programming languages C, C++ and Java, among many others.

This has actually been a handy little key going back decades. It first appeared on computer keyboards all the way back in 1965, back in the days of massive mainframes. It has since become a mainstay of modern keyboards. The meaning of the symbol depends entirely on the programming language, and even game developers find a variety of uses for it. Let’s get into what coders are using the tilde for.

Bitwise NOT operator

[embedded content]

This is likely the most common use of the tilde symbol when it comes to programming, as this method is the same in Javascript, C, C++, Python and several other computing languages. The bitwise NOT operator (yes it’s spelled that way) inverts all the bits of a binary number. This means that all zeroes become ones and all ones become zeroes. For instance, “0010” would become “1101.” 

This is a boon when optimizing systems and was actually used a lot when generating old-school video game graphics. It was a quick and dirty way to automatically invert colors. It’s also used to index files and find missing elements in strings. There are many ways in which coders rely on this tool, depending on the specific programming language. It can even be used to flip a numerical digit, like “5”, to its binary equivalent. 

There’s even something called a double bitwise NOT operator, which is represented with two tildes standing side by side. This is typically used to truncate decimals.

Class destructor

Programmers using C++ or C# tend to rely on something called a class destructor. This is a special function that runs when an object has been deleted. It’s primarily used to clean up resources, which help free allocated memory. Generally speaking, this is done by popping a tilde before the name of the object, or class, that will be deleted.

Video game programmers tend to use class destructors to free up memory when an object exits a player’s field of view. This includes stuff like enemies, projectiles and even user interface windows. The destructor eliminates texture buffers, physics engines and anything else connected to the deleted object. 

As you can imagine, large-scale open-world games would struggle without this tool. Objects are constantly deleted as a player moves throughout the world. Without class destructors, massive in-game assets would continue to hog the memory even when they aren’t present on the screen. That would make everything run as slow as molasses. 

General sibling selector

Programmers in CSS often use something called a general sibling selector, which is instigated with a tilde symbol. Simply put, this process automatically selects all matching elements that follow the tilde. This lets people target specific parts of the code even if they aren’t directly next to each other, which allows for batch changes. This differs from the adjacent sibling selector, which only selects the element that comes immediately after the “+” symbol.

There are several use case scenarios for a general sibling selector, most of which involve changing the visual elements of a user interface, website, or web app. It’s not popular in traditional video game development, because most engines don’t use CSS for core game logic or rendering, but it is often found in web-based games. Programmers also find it handy when it comes to game launchers, store pages and settings menus. Again, that’s because it’s used to quickly change up the visual style.

Don’t miss these tips!

We don’t spam! Read more in our privacy policy

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Hot this week

Topics

AI Is Thriving at Capital One

If one were making a list of the companies...

What are the animals in your home learning from each other?

LEARNING FROM EACH OTHER Leaf, Sunshine, and Cuddles The animals who...

Featured Artist | Darrell Black

Darrell Black Frankfurt, Germanyhttp://darrell-black.pixels.com/@definismart My Darrell Urban Black, an American visual...

European summer ‘deadliest’ for heatwaves

This summer was Europe’s deadliest on record, with more...

Are Crows and Parrots Really the Smartest Birds?

Kelsey McCune wanted to study smart birds, so naturally,...

Related Articles

Popular Categories

News Feed

Our writers on Antonelli’s title success and what it means

It’s been a couple of weeks since Kimi Antonelli became the youngest World Champion in Formula 1 history, so now feels like a perfect...

Button explains what will ‘keep Alonso going’ at Aston Martin

Jenson Button believes that Fernando Alonso’s re-signing with Aston Martin is hugely important for the team and, as long as he can see progress,...

Change these Fitbit Edge settings for a better experience

How to get more out of your fitness...

Yasiin Bey Revisits ‘The Ecstatic’ At Rare NYC Club Gig

For an artist who rarely performs in the United States, let alone his native New York, a chance to see Yasiin Bey is an...

Magic: The Gathering is getting a Netflix animated series. For real this time.

EntertainmentMagic The Gathering: Planeswalker is set to debut on Netflix in 2027.Magic The Gathering: Planeswalker is set to debut on Netflix in 2027.by ...

How much did home internet cost in 2001 vs 2026?

You're actually getting better value now than you...

How to make your Nintendo Switch 2 battery last longer

Try these tweaks if your Switch 2 won't...

5 excellent free Apple Watch apps every owner should know about

Plenty of watch apps are free to download...

‘Fatherland’ Wins Golden Frog at ToruńCAMERIMAGE 2026 — Full Winners List

With the end of ToruńCAMERIMAGE 2026, the world’s premier annual celebration of cinematography has come to a close. Poland’s largest film festival prides itself...

Common reasons your PC’s camera and microphone aren’t working

It's an annoying problem but one that can...

How to check which iOS version your iPhone is running

It's only ever just a few taps away. ...

A Hazeltine 1420 Lives Again

There was a time when buying a computer also meant picking out a compatible terminal. There were many to choose from, some good and...

What does an NPU do and why do so many laptops have them?

Almost nothing uses it yet. ...

Got an iPhone Duo? These 9 settings make it easier to use

Apple’s new foldable, the iPhone Duo, has proven popular enough that the company can’t keep the device in stock. While the Duo introduces a...

Checking your Apple Watch’s battery health is easier than you think

It just takes a couple of clicks and...

Work to replace old copper wire led to the FAA’s ground stop

TransportationIssues with a new router related to a fiber optic upgrade grounded thousands of flights on Friday.Issues with a new router related to a...

Popular articles

Our writers on Antonelli’s title success and what it means

It’s been a couple of weeks since Kimi Antonelli became the youngest World Champion in Formula 1 history, so now feels like a perfect...

Button explains what will ‘keep Alonso going’ at Aston Martin

Jenson Button believes that Fernando Alonso’s re-signing with Aston Martin is hugely important for the team and, as long as he can see progress,...

Change these Fitbit Edge settings for a better experience

How to get more out of your fitness...

Yasiin Bey Revisits ‘The Ecstatic’ At Rare NYC Club Gig

For an artist who rarely performs in the United States, let alone his native New York, a chance to see Yasiin Bey is an...

Magic: The Gathering is getting a Netflix animated series. For real this time.

EntertainmentMagic The Gathering: Planeswalker is set to debut on Netflix in 2027.Magic The Gathering: Planeswalker is set to debut on Netflix in 2027.by ...

How much did home internet cost in 2001 vs 2026?

You're actually getting better value now than you...

How to make your Nintendo Switch 2 battery last longer

Try these tweaks if your Switch 2 won't...

5 excellent free Apple Watch apps every owner should know about

Plenty of watch apps are free to download...

‘Fatherland’ Wins Golden Frog at ToruńCAMERIMAGE 2026 — Full Winners List

With the end of ToruńCAMERIMAGE 2026, the world’s premier annual celebration of cinematography has come to a close. Poland’s largest film festival prides itself...

Common reasons your PC’s camera and microphone aren’t working

It's an annoying problem but one that can...

How to check which iOS version your iPhone is running

It's only ever just a few taps away. ...

A Hazeltine 1420 Lives Again

There was a time when buying a computer also meant picking out a compatible terminal. There were many to choose from, some good and...

What does an NPU do and why do so many laptops have them?

Almost nothing uses it yet. ...

Got an iPhone Duo? These 9 settings make it easier to use

Apple’s new foldable, the iPhone Duo, has proven popular enough that the company can’t keep the device in stock. While the Duo introduces a...

Checking your Apple Watch’s battery health is easier than you think

It just takes a couple of clicks and...

Work to replace old copper wire led to the FAA’s ground stop

TransportationIssues with a new router related to a fiber optic upgrade grounded thousands of flights on Friday.Issues with a new router related to a...