Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #11636
| From | Chris Pyrgas <"chris (at)"@xsharp.eu> |
|---|---|
| Newsgroups | comp.lang.clipper.visual-objects |
| Subject | Re: Very interesting : XSharp development roadmap for 2018 |
| Date | 2018-05-15 01:44 +0300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <pdd3du$aes$1@gioia.aioe.org> (permalink) |
| References | (5 earlier) <f5lbfd1pr9hu2sja9deqc9s5ldc12tumsa@4ax.com> <flm5tsFa7f5U1@mid.individual.net> <b6scfd9ohkm07ps32a71hg4fudd7578mcu@4ax.com> <pd72gq$a15$1@gioia.aioe.org> <9m1kfdpn6o5iuefvl5jcjdmcg2b4fua32f@4ax.com> |
Hi Dick, >> Please compile and run the following code in VO: >> >> This should put the value of 100.00 in the fMoney local, right? Well, >> the comparison of fMoney == 100.00 returns false! > > In some extreme cirumstances I've seen rounding problems like this in > VO. However, there's a simple solution for this: > > fMoney:=Val(NTrim(fMoney)) > > This solves the problem completely. It may solve this, but it does so by coincidence and only under specific circumstances. If something has changed the internal setting for visible decimal spaces on fMoney, then it will not work. For example, add this code, before using the Val() trick: fMoney := 1.00000000000 * fMoney then the Val() trick does not work anymore. Not to mention it is extremely slow. Do you mean you use that after every calculation with float numbers? > So I real life I can't imagine that accounting software goes wrong > with these very small rounding differences. It's too small for that. > For comparing, yes. But I don't need to change datatypes for that; the > above trick will do the job as well. I posted an extremely simple sample which already goes wrong. If you start doing more complex calculations, start using multiplications and divisions and not only additions/subtractions on FLOAT numbers, then the precision problems appear a lot earlier. The biggest app I have written in VO is an accounting app, which is doing an extreme amount of calculations on money values and each one of them has to be absolutely precise, even just a 0.01 difference in end results causes nightmares to find out what's causing it. Very soon I realized that I could no way rely on FLOAT values to store money in xxxxx.xx format, so I thought about using INTs instead, which are faster anyway and then always divide by 100 in order to display the value on screen. That worked fine, but then we started selling this app to bigger customers that we had expected, and the range of values supported by INTs (2 billion cents) were not enough for them and unfortunately VO does not have a 64bit INT data type that we could simply use instead, so we ended up using floats again (REAL8s actually), using only their integer part and again dividing by 100 when displaying them on screen. If I had written this app in X#, I would had used the Decimal data type from the very beginning and would had saved probably 100s of hours programming, testing and debugging this inherent issue with the float type. Chris > > Or in other words: of course it's better to use the datatype in new > projects. But I see no reason to rush converting my programs to this > decimal datatype.... > > Dick >
Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Very interesting : XSharp development roadmap for 2018 stavros.spanos2@gmail.com - 2018-05-02 03:30 -0700
Re: Very interesting : XSharp development roadmap for 2018 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-05-09 23:49 +0200
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-10 07:53 +0200
Re: Very interesting : XSharp development roadmap for 2018 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-05-11 00:32 +0200
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-11 12:06 +0200
Re: Very interesting : XSharp development roadmap for 2018 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-05-11 12:26 +0200
Re: Very interesting : XSharp development roadmap for 2018 Chris Pyrgas <"chris (at)"@xsharp.eu> - 2018-05-11 16:05 +0300
Re: Very interesting : XSharp development roadmap for 2018 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-05-11 20:11 +0200
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-11 20:32 +0200
Re: Very interesting : XSharp development roadmap for 2018 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-05-12 16:57 +0200
Re: Very interesting : XSharp development roadmap for 2018 Chris Pyrgas <"chris (at)"@xsharp.eu> - 2018-05-12 18:52 +0300
Re: Very interesting : XSharp development roadmap for 2018 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-05-15 00:06 +0200
Re: Very interesting : XSharp development roadmap for 2018 Chris Pyrgas <"chris (at)"@xsharp.eu> - 2018-05-15 01:44 +0300
Re: Very interesting : XSharp development roadmap for 2018 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-05-15 12:36 +0200
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-13 15:01 +0200
Re: Very interesting : XSharp development roadmap for 2018 Chris Pyrgas <"chris (at)"@xsharp.eu> - 2018-05-12 16:53 +0300
Re: Very interesting : XSharp development roadmap for 2018 Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2018-05-13 10:08 +0200
Re: Very interesting : XSharp development roadmap for 2018 Chris Pyrgas <"chris (at)"@xsharp.eu> - 2018-05-13 16:01 +0300
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-13 15:12 +0200
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-13 15:13 +0200
Re: Very interesting : XSharp development roadmap for 2018 Chris Pyrgas <"chris (at)"@xsharp.eu> - 2018-05-13 16:54 +0300
Re: Very interesting : XSharp development roadmap for 2018 Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2018-05-13 17:55 +0200
Re: Very interesting : XSharp development roadmap for 2018 Chris Pyrgas <"chris (at)"@xsharp.eu> - 2018-05-13 19:37 +0300
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-13 19:03 +0200
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-13 18:40 +0200
Re: Very interesting : XSharp development roadmap for 2018 Chris Pyrgas <"chris (at)"@xsharp.eu> - 2018-05-14 00:33 +0300
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-14 06:08 +0200
Re: Very interesting : XSharp development roadmap for 2018 Chris Pyrgas <"chris (at)"@xsharp.eu> - 2018-05-14 15:50 +0300
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-14 16:01 +0200
Re: Very interesting : XSharp development roadmap for 2018 Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2018-05-14 15:13 +0200
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-14 16:03 +0200
Re: Very interesting : XSharp development roadmap for 2018 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-05-15 00:08 +0200
Re: Very interesting : XSharp development roadmap for 2018 Chris Pyrgas <"chris (at)"@xsharp.eu> - 2018-05-15 02:07 +0300
Re: Very interesting : XSharp development roadmap for 2018 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-05-15 12:17 +0200
Re: Very interesting : XSharp development roadmap for 2018 Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2018-05-15 13:41 +0200
Re: Very interesting : XSharp development roadmap for 2018 Chris Pyrgas <"chris (at)"@xsharp.eu> - 2018-05-15 16:13 +0300
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-15 05:41 +0200
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-11 15:57 +0200
Re: Very interesting : XSharp development roadmap for 2018 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-05-11 19:36 +0200
Re: Very interesting : XSharp development roadmap for 2018 "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-05-11 20:37 +0200
csiph-web