Skip to content

Instantly share code, notes, and snippets.

@davidlegit
davidlegit / ceil_floor_with_precision.php
Created October 7, 2020 12:01 — forked from gh640/ceil_floor_with_precision.php
PHP: ceil() and floor() with precision
<?php
function ceil_plus($value, $precision = 1) {
return round($value + 0.5 * pow(0.1, $precision), $precision, PHP_ROUND_HALF_DOWN);
}
function floor_plus($value, $precision = 1) {
return round($value - 0.5 * pow(0.1, $precision), $precision, PHP_ROUND_HALF_UP);
}
@davidlegit
davidlegit / centos-php7-install.sh
Last active April 10, 2016 18:25 — forked from risyasin/centos-php7-install.sh
PHP7 on Fedora 23 with php-fpm
## Create a source directory
## mkdir /usr/src/php7
## cd /usr/src/php7
## copy this files as /usr/src/php7/install.sh
## aria2c https://gist.githubusercontent.com/risyasin/92075324caa9a46bfd5c/raw/83e0851c42afc4f3557bc4aea02197ddf92fed73/centos-php7-install.sh
## php7 compile requirements
dnf install -y git
dnf install -y gcc bison automake autoconf
@davidlegit
davidlegit / gist:6028508
Last active December 19, 2015 22:38
Demonstration of bcsub to solve the problem of php float E-n exponential notation results from subtraction. Although unintentional this also demonstrates an incorrect result using the php minus operator when subtracting floats.
<?php
if (!function_exists('bcsub')) {
echo "install bcmath\nredhat: yum install php-bcmath\n";
exit;
}
$a = '1.11111112';
$b = '1.11111111';