Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#CCCCFF
#include<stdio.h>

void main()
{
    short a;=533;
    int b;=6789;
    long c;=3269326;

    float d;
    double e;
    double f;

    a=533;
    b=6789;
    c=466438237;

    d=a;
    e=b;
    f=c;
    d/=7;
    e/=30;
    f/=789;

    printf("Value of d is %f\n", d);  // Correct value of d i.e.     76.142860 is printed
    printf("Value of e is %f\n", e);  // Correct value of e i.e.    226.300000 is printed
    printf("Value of f is %f\n", f);  // Correct value of f i.e. 591176.472750 is printed
}

Risk Assessment Summary

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

FLP33-C

1 (low)

2 (probable)

1 (high)

P2

L3

References

  • Hatton 95 Section 2.7.3, "Floating-point misbehavior"
  • ISO/IEC 9899-1999 Section 5.2.4.2.2, "Characteristics of floating types <float.h>"