Keil Logo


Information in this article applies to:

  • C251 Version 3.50 or before


The following C251 program does not produce correct double precision results.

#pragma FLOAT64

double v1 = 4.0;
double v2 = 6.0;
double x1, x2;

void double_error (void) {
  x1 = v1/v2;          // result: 0.666666666666666666
  x2 = x1 + x1 + x1;   // wrong result: 1.0 should be 2.0
  x2 = x1 * v2;        // wrong result: 2.0 should be 4.0


The C251 Compiler V3.50 and earlier contains a potential problem in the run-time library which may cause this effect. It only occurs when the end result is exactly a power of 2 (i.e. 0.25. 0.5, 1.0, 2.0, 4.0, 8.0). It occurs while rounding-up the final result and causes the result to be off by a factor of 2.

The problem does not exist when you use constants that are calculated at the compiler level by the constant folding optimization.


This problem is resolved in C251 Compiler V3.51 and available in C251 V3.53a.


Last Reviewed: Friday, May 20, 2005

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.