Re: [SQL] Round integer division

2010-06-26 Thread Jasen Betts
On 2010-06-25, Lee Hachadoorian lee.hachadoor...@gmail.com wrote: Is it documented anywhere that floating-point numbers round scientifically, that is 0.5 rounds to the nearest even number? That's swiss rounding. And no, as I understand it documented that most arithmetic) is platform

Re: [SQL] Round integer division

2010-06-26 Thread Jasen Betts
On 2010-06-25, Lee Hachadoorian lee.hachadoor...@gmail.com wrote: On 06/25/2010 07:00 PM, Scott Marlowe wrote: That all floating point representations are approximate? But if it's error due to approximation, shouldn't the result be random? I tried this for a handful of larger numbers, and

[SQL] Round integer division

2010-06-25 Thread Lee Hachadoorian
Is it documented anywhere that floating-point numbers round scientifically, that is 0.5 rounds to the nearest even number? Compare: SELECT round(2.5::real), round(2.5::numeric), round(3.5::real), round(3.5::numeric); generates 2 | 3 | 4 | 4 I stumbled across this when I was trying to use

Re: [SQL] Round integer division

2010-06-25 Thread Scott Marlowe
On Fri, Jun 25, 2010 at 6:53 PM, Lee Hachadoorian lee.hachadoor...@gmail.com wrote: Is it documented anywhere that floating-point numbers round scientifically, that is 0.5 rounds to the nearest even number? Compare: SELECT round(2.5::real), round(2.5::numeric), round(3.5::real),

Re: [SQL] Round integer division

2010-06-25 Thread Lee Hachadoorian
On 06/25/2010 07:00 PM, Scott Marlowe wrote: That all floating point representations are approximate? But if it's error due to approximation, shouldn't the result be random? I tried this for a handful of larger numbers, and it appears to consistently round to the even number. Wouldn't that

Re: [SQL] Round integer division

2010-06-25 Thread Adrian Klaver
On Friday 25 June 2010 3:53:01 pm Lee Hachadoorian wrote: Is it documented anywhere that floating-point numbers round scientifically, that is 0.5 rounds to the nearest even number? Compare: SELECT round(2.5::real), round(2.5::numeric), round(3.5::real), round(3.5::numeric); generates 2 |

Re: [SQL] Round integer division

2010-06-25 Thread Lee Hachadoorian
Thanks. That was a fairly recent post, too, but I couldn't come up with the right keyword search to find it. On 06/25/2010 07:25 PM, Adrian Klaver wrote: On Friday 25 June 2010 3:53:01 pm Lee Hachadoorian wrote: Is it documented anywhere that floating-point numbers round scientifically,