dimanche 9 août 2015

PHP function 'pow' weird result

I was working on a code and I could not understand the weird result I was getting.

<?php

    $a = 0.01;  
    $p = pow(0.1, 2); // result: 0.01

    if( $a < $p ){
        echo "true";
    }

?>

The result of this condition is always "true" while both of the variables have same value, but the result coming from pow is changing something internally. Seems like I would not be able to rely on this function. Would someone please help me figuring this out ?

Thank you

Aucun commentaire:

Enregistrer un commentaire