/*
   ###########################################################################
   This function converts any signed scientific notation number into the
   equivalent arbitrary precision normal BC number string format.

   It is set to a default of up to 100 internal working decimals.

   NOT case sensitive.

   '12.345e+9'  would be converted to  '12345000000'

   '12.345E-9'  would be converted to  '0.000000012345'

   ###########################################################################
*/

   function Sci_to_BC_Num ($SciNotationStr)
{
   $X = StrToUpper(trim($SciNotationStr));

// Return ERROR if non-numeric argument.
   if (!Is_Numeric($X)) {return 'Sci_to_BC ERROR';}

   $DECIMALS = 100; // Internal working decimals limit.

/* -------------------------------------------------------
   Check if scientific notation (contains E). If not, then
   assume number is already in normal BC format and return
   it as-is, unchanged.
*/
   $i = StrPos($X, 'E');
        if ($i === FALSE)
           {
            if (StrPos($X, '.') === FALSE) { return $X;}
            return RTrim(RTrim($X, '0'), '.');
           }

   $x = substr($X, 0, $i);

// ---------------------------------------------------------------------
// Get exponent value as BC multiplier.

   $E = $Exp10 = Str_Replace('E', '', StrRChr($X, 'E'));

   if ($E >= 0)
      {$E = '1' . Str_Repeat('0', $E);}
   else
      {$E = '0.' . Str_Repeat('0', abs($E)-1) . '1';}

// Construct normal BC format number.
   $X = bcMul($x,$E, $DECIMALS);

// Suppress any trailing zeros.
   $X = RTrim(RTrim($X, '0'), '.');

   return $X;

} // End of  Sci_to_BC_Num (...)