codebyko.se

N/A

Main menu

Skip to primary content
Skip to secondary content
  • Home
  • WordPress Plugins

Monthly Archives: October 2011

MySQL round half even emulation

Posted on 5 October, 2011 by karloskar
Reply

I needed to emulate php’s PHP_ROUND_HALF_EVEN behaviour in mysql and did this:

SELECT IF(MOD(col,2)=1.5), FLOOR(col), ROUND(col))

Where col is a float value.

Edit: It seems as mysql’s ROUND() function does this per default. I should have read TFM.

Posted in Okategoriserade | Leave a reply

Archives

  • May 2012
  • October 2011
  • May 2011
  • November 2010

Meta

  • Log in
Proudly powered by WordPress