0

I have a simple formula, I don't want Delphi to round the result.

I need 15 number in the decimal part in Delphi7.

77600000/22400000*2146816 = 7437183.99998

Delphi result: 7437183.0 ?!!!!

fantaghirocco
  • 4,761
  • 6
  • 38
  • 48
nahid
  • 1
  • Delphi will give an approximate answer for floating point calculations. That said, are you using `single` or `double` as your type? If you want more accurate results then you should use `double`. – Graymatter Oct 06 '15 at 07:22
  • Are you familiar with [any of these](https://www.google.nl/search?q=what+every+programmers+floating&ie=utf-8&oe=utf-8&gws_rd=cr&ei=DngTVuX7C8SZUZLmiYgE) – Jan Doggen Oct 06 '15 at 07:29
  • 2
    I've closed this as a dupe of the standard question covering binary floating point representability. One could equally have closed it as off topic since it does not contain the code that led to the stated output. To be very clear though, no binary floating point value will ever equal 7437183.99998 since that number is not representable. But let us also be quite clear that with exact arithmetic, 77600000/22400000*2146816 = 7437184. – David Heffernan Oct 06 '15 at 07:52
  • 3
    So, if you present code to reproduce the output that you report, in an edit to the question, then we can reopen and deal with those specifics. – David Heffernan Oct 06 '15 at 07:55

0 Answers0