I have a problem on my laravel code. I want to check condition and show up using dd my code here.
$ca = floatval($sw->terminal_ca); // $sw->terminal_ca from postgresql type number(8,6) = 0.003480 $max_ca = $this->terminal_ca*(1+($this->tolerance/100)); // $this->terminal_ca from postgresql type number(16,4) = 0.0029 // $this->tolerance from postgresql type number(16,4) = 20.0000 dd( $ca, $max_ca, ($ca <= $max_ca));
but my result here
not acceptable. it should be true. What’s wrong on my code? How can I solve it?
Advertisement
Answer
I round it before comparison is ok now. Thank @El_Vanja
$ca = round($ca, 6); $min_ca = round($min_ca, 6);