Hi Vignesh!



 Vignesh_Baskaran:


Is this normal to have a slight discrepancy?



Yes, such a discrepancy is to be expected due to floating-point
round-off error.



Can someone please explain why this discrepancy happens with some under the hood explanation or please point me to resources to understand this in depth?



In short, when you use  floating-point arithmetic to perform operations
in different orders that should be mathematically equivalent, you, in
general, expect to get (slightly) different results.
In particular, the associative law no longer holds, in that with
floating-point arithmetic, (a + b) + c  !=  a + (b + c).  (The
two expressions can be equal for some values of a, b, and, c,
but, in general, will differ.)
For a start, you can look at the WIkipedia article for round-off error,
and dig into it more deeply, if you like, with Goldberg’s classic paper,
“What Every Computer Scientist Should Know About Floating-Point Arithmetic.” 2
Best.
K. Frank