Daniel Lemire's blog

, 2 min read

Funny differences between Mysql and Postgresql

4 thoughts on “Funny differences between Mysql and Postgresql”

  1. Scott says:

    Regarding the rounding of 0.5, I was also taught that it should round to 1. But what about 1.5? I would guess that Daniel was taught that it rounds to 2; I was taught that it also rounds to 1. I learned this in lab courses in undergraduate physics. The general rule was (is) that if the digit to the immediate left of the positition being rounded is even, round up; otherwise round down. The rationale is that otherwise, on average, you will end up
    rounding up more often than down, skewing results slightly.

  2. Scott says:

    Hmm. Should have tried it BEFORE posting the last comment so as to avoid having to post another. It looks to me like MySQL follows a similar rounding rule, but with even/odd reversed: if the preceding digit is odd, round up; otherwise round down. So, for example, 1.5 and 2.5 both round to 2.

  3. Joseph Scott says:

    As to why MySQL rounds the way it does, that was directly from the MySQL docs. I didn’t really but it either, but it looks like that is their “official” explanation.