Skip to content

Gendarme.Rules.Correctness.DoNotRoundIntegersRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

DoNotRoundIntegersRule

Assembly: Gendarme.Rules.Correctness
Version: git

Description

This rule check for attempts to call System.Math.Round, System.Math.Ceiling, System.Math.Floor or System.Math.Truncate on an integral type. This often indicate a typo in the source code (e.g. wrong variable) or an unnecessary operation.

Examples

Bad example:

public decimal Compute (int x)
{
    return Math.Truncate ((decimal) x);
}

Good example:

public decimal Compute (int x)
{
    return (decimal) x;
}

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally