note 84766 added to function.ceil
| From: | fuck at you dot com | Date: | Tue, 29 Jul 2008 10:55:42 +0000 |
| Subject: | note 84766 added to function.ceil | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-142888@lists.php.net to get a copy of this message | ||
What the hell is with all of the string manipulation when you are carrying out a mathematical
operation?
Use something like:
sub round_it {
my $num = shift;
my $sig = shift;
my $neg = 0;
if ($num < 0) {
$num += -(2 * $num);
$neg = 1;
}
my $ret = int($num * (10 ** $sig)) / (10 ** $sig);
if ($ret < $num) {
if (($num * (10 ** length($ret))) % ($ret * (10 ** length($ret))) > 5) {
$ret += 100 / (10 ** length($ret));
}
}
return $neg == 1 ? -$ret : $ret;
}
for it to be done logically and correctly.
Jesus. No wonder the term "PHP programmer" is also meant to mean "Idiot".
----
Server IP: 130.206.1.5
Probable Submitter: 82.38.255.42
----
Manual Page -- http://www.php.net/manual/en/function.ceil.php
Edit -- https://master.php.net/note/edit/84766
Del: integrated -- https://master.php.net/note/delete/84766/integrated
Del: useless -- https://master.php.net/note/delete/84766/useless
Del: bad code -- https://master.php.net/note/delete/84766/bad+code
Del: spam -- https://master.php.net/note/delete/84766/spam
Del: non-english -- https://master.php.net/note/delete/84766/non-english
Del: in docs -- https://master.php.net/note/delete/84766/in+docs
Del: other reasons-- https://master.php.net/note/delete/84766
Reject -- https://master.php.net/note/reject/84766
Search -- https://master.php.net/manage/user-notes.php