Page 1 of 1

Division Operator as Unsupported, WTF!?!

Posted: Thu May 26, 2005 10:16 pm
by nigma

Code: Select all

// Function to convert number to scientific notation and return as formatted string.
// Yes, I realize I could do the same with sprintf()
function toSci($n) {
  $power = 0;
  while ($n >= 10) {
    $n /= 10;
    $power++;
  }
  return ($power) ? $n.'e+'.$power : $n;
}
Lol, i'm getting a message that the division operator in this section of code is unsupported, WTF!?!

Posted: Thu May 26, 2005 10:30 pm
by SBro
Works fine for me when I tested? what's the exact error your getting, because i got no errors and an expected result.

Posted: Thu May 26, 2005 11:50 pm
by nigma
I was using the function in the following context:

Code: Select all

list($somevar) = toSci(@mysql_fetch_array(@mysql_query("query")));
I was neglecting the fact that I was trying to make the assignment using the list function. Because my toSci function wasn't returning an array like list() expected I got the error. Anyway, problem solved, thanks for showing interest.