Recent

Author Topic: display of floating-point numbers  (Read 1878 times)

mtanner

  • Sr. Member
  • ****
  • Posts: 287
display of floating-point numbers
« on: May 29, 2017, 08:47:06 am »
I have:
var X:double;
const DP=6;
Writeln(X:7+DP:DP,'  ',X:20:12);

so the same value being displayed in two ways. What I get for some values of X is:
1.48148E+0006  0.148148148148
3.33333E-0016   0.333333333333
2.96296E-0016   0.296296296296

The right-hand value is the correct value. a variable X declared as double. Why does the first column display incorrectly? I assume this is a bug.

If I code X:13:6 instead of X:7+DP:DP then I get correct results.
If I code X:(7+DP):DP then I also get correct results.

 

TinyPortal © 2005-2018