Reputation: 648
I have a code like this $new_amount = round(($old_amount/53),2);
amount may be 1,2, ...,10000;
How get exact $old_amount
from $new_amount;
Now i tried to use
$old_amount = ceil($new_amount);` AND `$old_amount = floor($new_amount);
but not working properly; please help me;
Upvotes: 0
Views: 111
Reputation: 4171
If you need the exact amount, don't change the $old_amount while creating $new_amount. So you can use $old_amount later.
There is no way to back. Both Ceil() and floor() functions can't give you what you want.
Upvotes: 0
Reputation: 7905
You can't, once you round a value you get rid of the extra precision. This precision is lost. However, the old value is still stored in the $old_amount
variable.
Upvotes: 3