Ошибка сравнения двух двойных переменных в PHP ⇐ Php
-
Anonymous
Ошибка сравнения двух двойных переменных в PHP
I have encountered this strange behaviour in PHP.
My code is:
$pra = $this->PercentualeRicaricoApplicata; // 37 $current = floatval($currentPercentage->RicaricoPercentuale); // 37 $lower = floatval($lowerPercentage->RicaricoPercentuale); // 27 myecho(gettype($pra) . ' - ' .gettype($current) . ' - ' . gettype($lower)); echo '
pra = current: ';var_dump($pra >= $current); echo '
current >= pra: ';var_dump($current >= $pra); echo '
pra lower: ';var_dump($pra > $lower); and I get these results:
double - double - double pra = current: bool(true) current >= pra: bool(false) pra lower: bool(true) I can't come around why (pra = pra) aren't working with double variables.
Источник: https://stackoverflow.com/questions/781 ... les-in-php
I have encountered this strange behaviour in PHP.
My code is:
$pra = $this->PercentualeRicaricoApplicata; // 37 $current = floatval($currentPercentage->RicaricoPercentuale); // 37 $lower = floatval($lowerPercentage->RicaricoPercentuale); // 27 myecho(gettype($pra) . ' - ' .gettype($current) . ' - ' . gettype($lower)); echo '
pra = current: ';var_dump($pra >= $current); echo '
current >= pra: ';var_dump($current >= $pra); echo '
pra lower: ';var_dump($pra > $lower); and I get these results:
double - double - double pra = current: bool(true) current >= pra: bool(false) pra lower: bool(true) I can't come around why (pra = pra) aren't working with double variables.
Источник: https://stackoverflow.com/questions/781 ... les-in-php
Мобильная версия