<div dir="auto">Thanks a lot!  And must we deal with each number accuracy, or this does the framework? Middle computations<div dir="auto">Also approximate</div><div dir="auto"><br></div><div dir="auto">For example, making 11 sums</div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">вт, 21 сент. 2021 г., 13:39 <a href="mailto:vmarchetti@kshell.com">vmarchetti@kshell.com</a> <<a href="mailto:vmarchetti@kshell.com">vmarchetti@kshell.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">This reference: <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types" target="_blank" rel="noreferrer">https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types</a><div>details that in the Microsoft .NET C# environment, the numeric double type is an 8-byte representation, and offers about 16 digits of precision.</div><div><br></div><div>In my experience, in those specific cases where numeric precision needs to be carefully dealt with, the solution is not to round the results of a calculation; rather the solution is to look at where two double values are being compared for equality, and replacing the comparison</div><div><br></div><div>if ( a==b) { .... }</div><div><br></div><div>with </div><div>if ( abs(a-b) < tolerance ) { ... }</div><div><br></div><div>and choosing a value of tolerance is can be something like</div><div><br></div><div>double tolerance = 1.0e-15 * Math.Max( abs(a), abs(b))</div><div><br></div><div>Vince Marchetti</div><div><br></div><div><div><br><blockquote type="cite"><div>On Sep 21, 2021, at 1:04 AM, Konstantin Smirnov <<a href="mailto:konstantin.e.smirnov@gmail.com" target="_blank" rel="noreferrer">konstantin.e.smirnov@gmail.com</a>> wrote:</div><br><div><div dir="auto">Hi<div dir="auto">When adding double numbers in .cs script, must we think about every digit accuracy, or it's approximate numbers, so we can treat them as approximate with e-7, or so? 15? </div><div dir="auto"><br></div><div dir="auto">Can we do calc and round afterwards? </div></div>
_______________________________________________<br>x3d-public mailing list<br><a href="mailto:x3d-public@web3d.org" target="_blank" rel="noreferrer">x3d-public@web3d.org</a><br><a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" target="_blank" rel="noreferrer">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br></div></blockquote></div><br></div></div></blockquote></div>