Query module PossibleLossOfPrecision

name
Possible loss of precision
description
Dividing or multiplying integral expressions and converting the result to a floating-point value may result in a loss of precision.
kind
problem
problem.severity
error
precision
high
id
cs/loss-of-precision
tags
reliability correctness security external/cwe/cwe-190 external/cwe/cwe-192 external/cwe/cwe-197 external/cwe/cwe-681

Imports

csharp

The default C# QL library.

Predicates

convertedToFloatOrDecimal

Holds if e is converted to type t which is a float or a decimal.

exactDivision

Holds if div is an exact integer division.

small

Holds if e is a constant multiplication that does not overflow.

Classes

DivLossOfPrecision

A division expression that may result in a loss of precision.

LossOfPrecision

An expression that may result in a loss of precision.

MulLossOfPrecision

A multiplication expression that may result in a loss of precision.