# Remove Double Negations

# Description

Removes pairs of negations from boolean expressions until only zero or one negation is left.

# Benefits

Improves the readability of the code, by removing cascaded negations of boolean expressions.

# Tags

# Code Changes

# Example based on an even number of negations


boolean a = !!true; // 2 times


boolean a = true; // removed negations completely

# Example based on an odd number of negations


boolean a = !!!true; // 3 times


boolean a = !true; // reduced to one time

🛠️ Auto-refactor Available

You can auto-refactor this with jSparrow.
Drop this button to your Eclipse IDE workspace to install jSparrow for free:

Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client

Need help? Check out our installation guide.

# Properties

Property Value
Rule ID RemoveDoubleNegation
First seen in jSparrow version 2.7.0
Minimum Java version 1.1
Remediation cost 2 min