Updated
I agree with Ed Cottrell that your problem is how you are storing your data in the db. However, if this is a project where you are already looking at a large set of data that is already stored as an exponent then this function I wrote should work for you. It should work for positive and negative bases and exponents. It basically mimics the way you would do the operation by hand.
I was not able to figure out a way to do it using math functions. If someone knows how to do it better please post. In the meantime, I had fun writing this.
Hope it helps you out!
function getRealNumber($number){
//Parse the base and exponent.
preg_match('/^(.*?)E[\-|\+](.*?)$/', $number, $data);
$base = $data[1];
$exp = $data[2];
//Test to see if the base is negative.
if(preg_match('/\-/', $base)){
$base = str_replace('-', '', $base);
$isNegative = TRUE;
}
//Capture the offset of the decimal point.
preg_match('/\./', $base, $position, PREG_OFFSET_CAPTURE);
$offset = $position[0][1]; //This is the offset of the decimal point.
$string = str_replace('.', '', $base); //Get numbers without decimal.
$length = strlen($string); //Get the length of string.
//Test to see if we are adding zeros to the end or beginning of string.
if(preg_match('/E\+/', $number)){
//Let's move the decimal.
if($length > ($exp + $offset)){
$string = substr_replace($string, '.', ($exp + $offset), 0);
} else {
$string = $string . str_repeat('0', $exp - ($length - $offset));
}
}elseif(preg_match('/E\-/', $number)){
//Calculate the number of zeros needed to add and append them.
if($offset > $exp){
$string = substr_replace($string, '.', $offset, 0);
} else {
$string = '0.' . str_repeat('0', $exp - $offset) . $string;
}
}
//Add the negative sign if we need to.
if(!$isNegative){
return $string;
} else {
return '-' . $string;
}
}
$policy_number = "2.9992020830803E+18";
echo getRealNumber($policy_number);
//Will output 2999202083080300000