Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread allan gottlieb
On Sat, Aug 22 2015, Mike Gilbert wrote: > On Sat, Aug 22, 2015 at 1:32 PM, Alan McKinnon > wrote: >> I can tell you that equality comparisons on floats are problematic, and >> always will be due to how they are stored (double-precision floats, >> inhernetly inexact). This is not a "problem" per

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Paul Colquhoun
On Sat, 22 Aug 2015 16:57:41 hw wrote: > Am 22.08.2015 um 15:43 schrieb Alan McKinnon: > > On 22/08/2015 15:26, hw wrote: > >> Hi, > >> > >> I have the following in a perl script: > >>if ($a != $b) { > >> > >> print "e: '$a', t: '$b'\n"; > >> > >>} > >> >

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Mike Gilbert
On Sat, Aug 22, 2015 at 1:32 PM, Alan McKinnon wrote: > I can tell you that equality comparisons on floats are problematic, and > always will be due to how they are stored (double-precision floats, > inhernetly inexact). This is not a "problem" per se, it's a systemic > side effect of how our comp

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Fernando Rodriguez
On Saturday, August 22, 2015 3:26:56 PM hw wrote: > > Hi, > > I have the following in a perl script: > > >if ($a != $b) { > print "e: '$a', t: '$b'\n"; >} > > > That will print: > > e: '69.99', t: '69.99' > > > When I replace != with ne (if ($a ne $a) {), it doesn'

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Michael Orlitzky
On 08/22/2015 01:27 PM, allan gottlieb wrote: >> >> Floating point addition isn't even commutative: >> >> > 0.1 + 0.2 + 0.3 >> 0.6001 >> > 0.1 + (0.2 + 0.3) >> 0.6 > > That demonstrates non-associativity. I believe floating point is > commutative: a+b = b+a > Derp, thanks, y

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Alan McKinnon
On 22/08/2015 17:38, Alexander Kapshuk wrote: > On Sat, Aug 22, 2015 at 4:26 PM, hw wrote: >> >> Hi, >> >> I have the following in a perl script: >> >> >> if ($a != $b) { >> print "e: '$a', t: '$b'\n"; >> } >> >> >> That will print: >> >> e: '69.99', t: '69.99' >> >> >> When I

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Alan McKinnon
On 22/08/2015 16:57, hw wrote: > > > Am 22.08.2015 um 15:43 schrieb Alan McKinnon: >> On 22/08/2015 15:26, hw wrote: >>> >>> Hi, >>> >>> I have the following in a perl script: >>> >>> >>>if ($a != $b) { >>> print "e: '$a', t: '$b'\n"; >>>} >>> >>> >>> That will print: >>>

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread allan gottlieb
On Sat, Aug 22 2015, Michael Orlitzky wrote: > On 08/22/2015 09:42 AM, R0b0t1 wrote: >> https://en.wikipedia.org/wiki/Round-off_error >> https://en.wikipedia.org/wiki/Machine_epsilon >> >> Either add a tolerance (a - b <= t) or compare them as strings as >> you've been doing. >> > > You probably

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Michael Orlitzky
On 08/22/2015 09:42 AM, R0b0t1 wrote: > https://en.wikipedia.org/wiki/Round-off_error > https://en.wikipedia.org/wiki/Machine_epsilon > > Either add a tolerance (a - b <= t) or compare them as strings as > you've been doing. > You probably want |a - b| <= t there =) But... that can cause proble

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Alexander Kapshuk
On Sat, Aug 22, 2015 at 4:26 PM, hw wrote: > > Hi, > > I have the following in a perl script: > > > if ($a != $b) { > print "e: '$a', t: '$b'\n"; > } > > > That will print: > > e: '69.99', t: '69.99' > > > When I replace != with ne (if ($a ne $a) {), it doesn't print. > > > Is

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Franz Fellner
On Sat, 22 Aug 2015 16:57:41 +0200, hw wrote: > > > Am 22.08.2015 um 15:43 schrieb Alan McKinnon: > > On 22/08/2015 15:26, hw wrote: > >> > >> Hi, > >> > >> I have the following in a perl script: > >> > >> > >>if ($a != $b) { > >> print "e: '$a', t: '$b'\n"; > >>} > >> >

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread hw
Am 22.08.2015 um 15:43 schrieb Alan McKinnon: On 22/08/2015 15:26, hw wrote: Hi, I have the following in a perl script: if ($a != $b) { print "e: '$a', t: '$b'\n"; } That will print: e: '69.99', t: '69.99' When I replace != with ne (if ($a ne $a) {), it doesn't

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Alan McKinnon
On 22/08/2015 15:26, hw wrote: > > Hi, > > I have the following in a perl script: > > > if ($a != $b) { > print "e: '$a', t: '$b'\n"; > } > > > That will print: > > e: '69.99', t: '69.99' > > > When I replace != with ne (if ($a ne $a) {), it doesn't print. > > > Is th

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread R0b0t1
https://en.wikipedia.org/wiki/Round-off_error https://en.wikipedia.org/wiki/Machine_epsilon Either add a tolerance (a - b <= t) or compare them as strings as you've been doing.

[gentoo-user] 69.99 != 69.99

2015-08-22 Thread hw
Hi, I have the following in a perl script: if ($a != $b) { print "e: '$a', t: '$b'\n"; } That will print: e: '69.99', t: '69.99' When I replace != with ne (if ($a ne $a) {), it doesn't print. Is that a bug or a feature? And if it's a feature, what's the explanation?