-
Notifications
You must be signed in to change notification settings - Fork 3
Gendarme.Rules.Correctness.ReviewUseOfModuloOneOnIntegersRule(git)
Sebastien Pouliot edited this page Mar 2, 2011
·
1 revision
Assembly: Gendarme.Rules.Correctness
Version: git
This rule checks for a modulo one (1) operation on an integral type. This is most likely a typo since the result is always 0. This usually happen when someone confuses a bitwise operation with a remainder.
Bad example:
public bool IsOdd (int i)
{
return ((i % 1) == 1);
}
Good example:
public bool IsOdd (int i)
{
return ((i % 2) != 0); // or ((x & 1) == 1)
}
- This rule is available since Gendarme 2.0
You can browse the latest source code of this rule on github.com
Note that this page was autogenerated (3/17/2011 1:55:44 PM) based on the xmldoc comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Mailing List. Thanks!