Re: [fpc-pascal] floating point an FPC

2010-03-02 Thread Flávio Etrusco
On Mon, Mar 1, 2010 at 6:32 PM, ik wrote: > > http://ik.homelinux.org/ > > > On Mon, Mar 1, 2010 at 23:20, Jerry wrote: >> >> Don't compare floating points. Ever. Now you see why. > > So if I need for example to compare currency or something that is floating > point, how do I do that ? > Let me

Re: [fpc-pascal] floating point an FPC

2010-03-02 Thread Marco van de Voort
In our previous episode, Jerry said: > I'm not sure but maybe Hewlett-Packard calculators use BCD. (HP > calculators are known for their excellent numerical accuracy. Yes, at least the Saturn based ones do IIRC. They have 64-bit (16 digit) copro registers as you can see here: http://en.wikiped

Re: [fpc-pascal] floating point an FPC

2010-03-02 Thread Graeme Geldenhuys
ik wrote: > > So if I need for example to compare currency or something that is > floating point, how do I do that ? I think the Currency type is ok (special case with special handling), but other floating types are not. Alternatively, work with Integer types only, and then when you need to di

Re: [fpc-pascal] floating point an FPC

2010-03-01 Thread Jerry
On Mar 1, 2010, at 2:32 PM, ik wrote: http://ik.homelinux.org/ On Mon, Mar 1, 2010 at 23:20, Jerry wrote: Don't compare floating points. Ever. Now you see why. So if I need for example to compare currency or something that is floating point, how do I do that ? Also, don't write loops

Re: [fpc-pascal] floating point an FPC

2010-03-01 Thread Jonas Maebe
On 01 Mar 2010, at 22:32, ik wrote: > So if I need for example to compare currency or something that is floating > point, how do I do that ? If it's currency, use the currency type. The currency type is fixed point, not floating point, and that's exactly because floating point is inexact while

Re: [fpc-pascal] floating point an FPC

2010-03-01 Thread ik
http://ik.homelinux.org/ On Mon, Mar 1, 2010 at 23:20, Jerry wrote: > Don't compare floating points. Ever. Now you see why. > So if I need for example to compare currency or something that is floating point, how do I do that ? > > Also, don't write loops that calculate a floating point numbe

Re: [fpc-pascal] floating point an FPC

2010-03-01 Thread Jerry
Don't compare floating points. Ever. Now you see why. Also, don't write loops that calculate a floating point number which is then tested for equality to exit the loop. Also, it is a bad idea to test for > or < for exiting unless you know in advance an accidental equality result will not yi

Re: [fpc-pascal] floating point an FPC

2010-02-26 Thread Jonas Maebe
On 26 Feb 2010, at 11:37, ik wrote: I've made a small test: if (0.1+0.2) = 0.3 then The only compiler/interpator that actually tells that it equal is FPC. Then you are very lucky that FPC says it is equal. I've tested it using Javascript (in Firefox), Ruby, Python, C (gcc) and Perl. T

Re: [fpc-pascal] floating point an FPC

2010-02-26 Thread Marco van de Voort
In our previous episode, ik said: > I've made a small test: > > if (0.1+0.2) = 0.3 then > > The only compiler/interpator that actually tells that it equal is FPC. > > I've tested it using Javascript (in Firefox), Ruby, Python, C (gcc) and > Perl. > > Except FPC, everyone tells that 0.1+0.2 = 0.