0

So I found this small problem.


>> p1

p1 =

    0.0050

>> p2

p2 =

    0.0450

>> p1+p2 - 0.05

ans =

  -6.9389e-18


Obviously p1 + p2 is 0.05 but I think due to float problem when summed the result is not exactly equal to 0.05. Is there a way to restore p1+p2 back to 0.05? Thanks in advance. (above code is only for reference. It is not the goal of the question)

SharonZh
  • 1
  • 1
  • 1
    The linked answer explains how to compare floating-point numbers. If that is not the goal, please [edit] your post to describe exactly what you need to accomplish. – Cris Luengo Nov 01 '22 at 04:16

0 Answers0