PHP Floating Point Numbers


  • PHP recognizes two types of floating point numbers. The first is a simple numeric literal with a decimal point. The second is a floating-point number written in scientific notation. Scientific notation takes the form of [number]E[exponent], for example, 1.75E-2.

    Some examples of valid floating point numbers include: 

    3.14
    0.001
    -1.234 
    0.314E2  // 31.4 
    1.234E-5 // 0.00001234
    -3.45E-3 // -0.00345 

    Example : The PHP var_dump() function returns the data type and value of variables:

    <?php
    $x = 10.365;
    var_dump($x);
    echo "<br>";
    ?>   

Comments