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
it should be true.
What’s wrong on my code?
How can I solve it?
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
I have given static values in the controller and it’s working fine.
Kindly check your type in the database from where you are fetching data dynamically.
I round it before comparison is ok now. Thank @El_Vanja
$ca = round($ca, 6); $min_ca = round($min_ca, 6);