I've never used that library, so I can't help you with the first bit. Though I'd try setting the scale to roughly what you need it to be, 30 may not be supported. The docs are pretty skimpy on that library.
For the second bit, here's function to return a string formatted in scientific notation:
PHP Code:
// float2exp converts floats into exponential notation
function float2exp($num) {
if (0 == $num) { return "0E1";}
list($int, $dec) = split("\.", $num);
// Extract sign
if ($int[0] == "+" || $int[0] == "-") {
$sign = substr($int, 0,1);
$int = substr($int, 1);
}
if (strlen($int) <= 1) { // abs($num) is less than 1
$i=0;
for ($i=0; $dec[$i]=='0' && $i < strlen($dec); $i++);
$exp = -$i-1;
$mantissa = substr($dec,$i,1).".".substr($dec,$i+1);
} else { // abs($num) is greater than 1
$i=0;
for ($i=0; $int[$i]=='0' && $i < strlen($int); $i++);
$exp = strlen($int)-1 - $i;
$mantissa = substr($int,$i,1).".".substr($int,$i+1).$dec;
}
return ($sign . $mantissa . "E" . $exp);
}
I didn't write it, I just got it off of
www.php.net.