note 112039 added to function.intval

From: Date: Thu, 25 Apr 2013 17:27:07 +0000
Subject: note 112039 added to function.intval
Groups: php.notes 
Request: Send a blank email to php-notes+get-194623@lists.php.net to get a copy of this message
Do not use intval() when you really want round(). This is due to how PHP handles precision. echo number_format(8.20*100, 20), "<br />"; echo intval(8.20*100), "<br />"; echo floor(8.20*100), "<br />"; echo round(8.20*100), "<br />"; 819.99999999999988631316 819 819 820 ---- Server IP: 69.147.83.199 Probable Submitter: 130.207.133.154 ---- Manual Page -- http://php.net/manual/en/function.intval.php Edit -- https://master.php.net/note/edit/112039 Del: integrated -- https://master.php.net/note/delete/112039/integrated Del: useless -- https://master.php.net/note/delete/112039/useless Del: bad code -- https://master.php.net/note/delete/112039/bad+code Del: spam -- https://master.php.net/note/delete/112039/spam Del: non-english -- https://master.php.net/note/delete/112039/non-english Del: in docs -- https://master.php.net/note/delete/112039/in+docs Del: other reasons-- https://master.php.net/note/delete/112039 Reject -- https://master.php.net/note/reject/112039 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194623) next »