This question has already been answered:

var_dump(floatval($this->amount)); \\float(18000) var_dump($sum); \\float(18000) var_dump(floatval($this->amount)-$sum); die; \\float(-3.6379788070917E-12) 

What is wrong with subtraction?

Marked as a duplicate by participants Alexey Shimansky , rjhdby , Kromster , Denis Bubnov , D-side Mar 2 '17 at 16:32 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

    floatval() cannot be used with objects in this case an error of the E_NOTICE level will occur and the function will return 1 .

    Maybe this is the problem.

    • $ this-> amount - this string is actually '18000.00', but even without floatval () it returns the same, until it solved the problem through a round ($ result, 2) result - Igor Baranyuk
    • @ Igor Baranyuk amount stored as a string ........ mmm, something new ............ better keep it at once in a normal form - Alexey Shimansky