I have a project created by the Django framework and in this project, the visitors able to create cases, and this case have a target number field with the decimal type and the other visitors can vote to reach this target.
The Model of the case
The problem is fired when I try to make operation on it like "subtraction" to get the remaining like below code
result = case.target - case.vote
The result by default is rounding up and this not correct, after while from debugging here is the result
----- get_remaining ------
target : 6050.00
vote : 6.00
Decimal(target) : 6050.00
Decimal(vote) : 6.00
Decimal(target) - Decimal(vote) : 6.0E+3
Decimal(target) - Decimal(vote) : 6000.0
result: 6000.00
==================
I found the issue is converting the numbers to "Scientific notation" with the letter E this means the number 6.0 10 to the power of 3 equal 6000.0 !!!
Now I know the issue but I didn't know how to fix it? anyone have Idia how to fix it