note 118555 added to function.floor

From: Date: Sun, 27 Dec 2015 21:59:35 +0000
Subject: note 118555 added to function.floor
Groups: php.notes 
Request: Send a blank email to php-notes+get-204547@lists.php.net to get a copy of this message
Warning: do not use Seppili's function to floor with decimals. It will lead you to a lot of trouble because of float number precision. For example floordec(0.29, 2) will result in 0.28. Here's a little fix that will help you get around some problems: <?php function floordec($value,$decimals=2){ return floor($value*pow(10,$decimals)+0.5)/pow(10,$decimals); } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 188.129.56.227 ---- Manual Page -- http://php.net/manual/en/function.floor.php Edit -- https://master.php.net/note/edit/118555 Del: integrated -- https://master.php.net/note/delete/118555/integrated Del: useless -- https://master.php.net/note/delete/118555/useless Del: bad code -- https://master.php.net/note/delete/118555/bad+code Del: spam -- https://master.php.net/note/delete/118555/spam Del: non-english -- https://master.php.net/note/delete/118555/non-english Del: in docs -- https://master.php.net/note/delete/118555/in+docs Del: other reasons-- https://master.php.net/note/delete/118555 Reject -- https://master.php.net/note/reject/118555 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204547) next »