RE: TZF - Calculating
Jose Perez <[email protected]> Tue, 9 Sep 2003 16:18:51 +0000
| Newsgroups | gmane.comp.lang.delphi.topaz |
|---|---|
| Message-ID | <[email protected]> |
Chris Morgan wrote: > > Pierre, > > Nothing is wrong. > Have a look at > http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm#Q3 > > which discusses floating point accuracy. This FAQ does not explain the problem completely. One part of the problem is that humans use 10-base numbers but computers store them in binary format. 10-base numbers with a floating point, like 3.10, cannot always be converted with complete accuracy within the limits of the size of the real type used. This topic has been dicussed on some of the Delphi and Pascal newsgroups; you can check there for additional detail. Using the Extended type might solve the problem for this particular number, but it will appear again for other numbers. In Delphi 7, Real is equivalent to Double. The Currency type might be appropriate for your needs depending on the amount of precision that you need. Currency supports a maximum of four decimal points, while Extended supports a maximum of 19-20 significant digits. > Cheers, > Chris > > ----- Original Message ----- > From: "Pierre Wittwer" <[email protected]> > To: <[email protected]> > Sent: Tuesday, September 09, 2003 12:44 AM > Subject: TZF - Calculating > > > > Hi Topaz-users (or Delphi-users), > > > > I have a simple question. I have to convert a string into a > real.e.g. > > s = '3.10' and r is the real. > > Using Val(s,r,code) I get the real as r = > 3.09999999999854......instead of > > 3.10 > > Using the SReal of Topaz I get the correct '3.10' in the string. > But for > > calculating I need the real r > > What is wrong? Thank you for your help > > > > Pierre Wittwer > > CH Stans --^---------------------------------------------------------------- This email was sent to: [email protected] EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt Or send an email to: [email protected] TOPICA - Start your own email discussion group. FREE! http://www.topica.com/partner/tag02/create/index2.html --^----------------------------------------------------------------