[SR-6885] Double introduces the floating point precision issues #49434
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Attachment: Download
Additional Detail from JIRA
md5: 3d154c69ced19058be55a75c720e18c3
Issue Description:
Not sure if this is a swift bug or a floating point problem and an artifact of using floating point numbers.
I have a Double for total, when I add the amounts to total, the totals are incorrect because the floating point precision changes 135.15 to 135.15000000000009 or 135.149999999999999 or 12.12 becomes 12.119999999999999 which is incorrect
Most of the functions work with Int or Double, so when a decimal number is required, Double it is. However with this little error, the totals and display get muddled up and is a mess.
Sometimes zero is displayed as an exponential number.
These print fine when used with the print statement. However in math operations these cause an issue.
The text was updated successfully, but these errors were encountered: