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 that a bug or a

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 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.

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't print. Is

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Mike Gilbert
On Sat, Aug 22, 2015 at 1:32 PM, Alan McKinnon alan.mckin...@gmail.com 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

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 alan.mckin...@gmail.com 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

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; } That will print: e:

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 problems too.

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 want |a - b| =

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: e: '69.99', t: '69.99' When I replace !=

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 h...@gartencenter-vaehning.de 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

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, you're right =)

Re: [gentoo-user] 69.99 != 69.99

2015-08-22 Thread Alexander Kapshuk
On Sat, Aug 22, 2015 at 4:26 PM, hw h...@gartencenter-vaehning.de 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 Franz Fellner
On Sat, 22 Aug 2015 16:57:41 +0200, hw h...@gartencenter-vaehning.de 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