Why is PHP printing my number in scientific notation, when I specified it as .000021?
In PHP I have the following code:
<?PHP
$var = .000021;
echo $var;
?>
the output is 2.1E-5 !
Why? it should print .000021
Use number_format() to get what you're after:
print number_format($var, 5);
Also check sprintf()
2.1E-5 is the same number as 0.000021. That's how it prints numbers below 0.001. Use printf() if you want it in a particular format.
Edit If you're not familiar with the 2.1E-5
syntax, you should know it is shorthand for 2.1×10-5. It is how most programming languages represent numbers in scientific notation.