You really have two options:
1) Use float/double values and accept that you will get rounding errors in
all trivial and/non-trivial floating point calculations. You will have to
deal with this lack of precision appropriately for the type of calculation
you are performing. This is not a bug, this
Hi Alan,
While all this is find it does not explain the following observation using
the same CPU:
VS2015 the delta is zero
For all other VS dated back to 2003 the delta is non-zero.
In fact my friend has shown me his code that led him to question this:
He has a web server implementing that
> Does this mean one should not use C# when performing scientific
> calculations? The above information is interesting.
For financial calculations it is recommended to use System.Decimal
I don't know about scientific calculations.
Timotheus
___
You could also google for discussions about adding 0.1 and/or 0.2 multiple
times. That has fun results in every language too, for example
http://stackoverflow.com/questions/26120311/why-does-adding-0-1-multiple-times-remain-lossless
On 17 May 2016 at 13:23, Alan wrote:
There's no reason you should not use it if the errors you are seeing are
within the tolerance of floating point calculation limits. If you require
more accuracy then use double instead of float. If you require perfect
accuracy then you'll have to use a special type/library which provides more
Thanks for the reply. The following disclosure may not have anything to do
with explaining this but it highlights some inconsistency in .Net:
I know Mono is not exactly VS (well very close as Xamarin is now part of
Microsoft) but the following comparison is still valid and interesting:
VS2003,
At that level the rounding errors are down to how the compiler optimises
the calculations, whether the calculations are performed as actual 32bit
operations, or if they inflate to 64bit and then are rounded back to 32bit
results, the order of the operations and the actual CPU instructions used
to
Hi,
I am using MonoDevelop 5.10 and
the runtime Mono 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 16 13:19:08 UTC 20 in
a Mint17 (64bit) environment.
I am compiling the following code into .Net 4/4.5 and hence I believe I am
using dmcs version 4.2.3.0
A friend posts me the following piece of code: