Blog posts tagged "math"

bceval: arbitrary precision math for PHP without extensions

March 25th, 2008

I needed arbitrary precision math in PHP, and wasn’t willing to rebuild PHP to add the bcmath extensions. All hail backticks.

function bceval($expr) {
  return trim(`echo "$expr" | bc`);
}

Used like so

$end = bceval("$start + $batchsize - 1");

Wet cat territory.