<div dir="ltr"><br><br>On Fri, Oct 12, 2018 at 11:22 PM Nikos Alexandris <<a href="mailto:nik@nikosalexandris.net">nik@nikosalexandris.net</a>> wrote:<br>><br>><br>> Nikos wrote:<br>><br>[...]<br><div>></div>> >1.000000000000001 is most probably a too small difference to 1 considering<br>> >floating point precision limits.<br>><br>> It is. But then again, how do I decide how "loose" it can be?<br>><br>> 1.01?<br>> 1.001?<br>> 1.0001?<br><div><br></div><div>From experience I recommend 1 + 1e-6 which is a bit lower than the minimum single precision floating point limit.<br></div><div><br></div><div>Instead of<br></div><div><br></div><div>assert fractions_sum < 1.000000000000001, "Sum of fractions is > 1"</div><div><br></div><div>try</div><div><br></div><div><div>assert abs(fractions_sum - 1) < 1e-6, "Sum of fractions is != 1"</div></div><div><br></div><div>You should not go lower than 1e-15 because here you are hitting the double precision floating point limit.<br></div><div><br></div><div>Markus M<br></div></div>