-->

  • PHP numbers with floats


    PHP numbers with floats

    PHP Numbers

    You must have noticed one thing that whenever we take the numbers in the identification, then its conversion becomes automatic Or we can say that whatever number we give through Varible, the data type of the number is automatically correct according to its data type.Then, if you assign a string to the same variable, the type will change to a string. PHP numbers with integers

    This automatic conversion can sometimes break your code.

    PHP Floats


    A float is a number with a decimal point or a number in exponential form.

    2.0, 256.4, 10.358, 7.64E+5, 5.56E-5 are all floats.

    The float data type can commonly store a value up to 1.7976931348623E+308 (platform dependent), and have a maximum precision of 14 digits.

    PHP has the following functions to check if the type of a variable is float:


    • is_float()
    • is_double() - alias of is_float()


    Example

    Check if the type of a variable is float:



    <!DOCTYPE html>
    <html>
    <head>

    <title> PHP numbers with floats </title>

    </head>
    <body>

    <h1> </h1>


    <?php

    //  check if the type of a variable is integer
    $x = 574.92;
    var_dump(is_float($x));

    echo "<br>";

    // check again

    $z = 542;
    var_dump(is_float($z));



    ?>


    </body>
    </html>





    bool(true)
    bool(false)




    NOTE :- Video on This Topic :- Soon




    Have a Nice Stay Here : - )



  • 0 comments:

    Post a Comment

    For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.