Home > User Support > CoverageMaster winAMS FAQ

CoverageMaster winAMS FAQ

Test Data Settings

301_05: I set an expected value for a floating-point variable, but even when the simulation result is different from the expected value, the test result comes out as "OK". Why?

Question:

I set an expected value for a floating-point variable, but even when the simulation result is different from the expected value, the test result is "OK" Why?

Answer:

This is due to the number of significant digits of the floating-point variable. For example, if a floating-point variable is of type float, the variable has size of 4 bytes (32-bits). The 32-bits are used as shown in the figure below. The 23-bit fraction portion indicates the number of significant digits that can be represented. In binary this is 24-bits (the 23-bit fraction + 1 sign bit). In decimal it is approximately 7 significant digits.


In a test like the example below, a float type variable @fin is given the value [1.123456789], but since a float's precision is limited to 7 significant digits, CoverageMaster rounds the value up to [1.123457], following the IEEE 754 default "Round to nearest, ties to even" rule. This is the final value that is given to the parameter when running the test.

The same process occurs for values entered as Expected Values in the Output columns of the Test CSV file. Therefore, even if [1.123456789] was entered, the actual expected value registered by the program is also [1.123457]. Since the expected value and the result are both [1.123457], the result of the test will come out as [OK] because they match.

In the Result CSV file, the actual value that was given to the variable during simulation is output (in this case, [1.123457]).

Example:

float gb_fval;

void floattest(float fin)
{
    gb_fval = fin;
}


Input CSV File:

Result CSV file:

 

Related Technical Tips Search

Other technical tips in GAIO's web site can be searched for using the links below.

Search key word link: float | floating-point | expected value
Technical Tips Google Search


Information Links