Does Math.Sqrt cache its own results?

I don't have .net 4 installed but you can vrify this easily by viewing the said method in reflector this is the only way that you'll be sure to see what's going on.

I don't have .net 4 installed but you can vrify this easily by viewing the said method in reflector. This is the only way that you'll be sure to see what's going on.

1 I actually checked this out in both ildasm and .net reflector. It appears that there is no caching at the . NET level because both show that Math.

Sqrt is actually an extern call. – Daniel Joseph Jun 16 '10 at 14:35 You can't see this using reflector because it is an extern call. You could download the sources of the shared source reference implementation from Microsoft and have a look there.

You would see that Math. Sqrt simply is a call to the sqrt() function in math. H of C++.

– 0xA3 Jun 16 '10 at 14:55.

I don't belive so. You can try and do a benchmark, call Math. Sqrt on 1000.000 different numbers and then on 1000.000 same numbers, the time taken should be similar.

May you can have a look into reflector which reveals you (at least the unmanaged parts) of the Math. Sqrt function code. If you need a cache, you should create one on your own with some kind of hashtable.

Note that you should leave an epsilon, that is for example 1.0000000 should be considered the same as 1.00000001, otherwise you get into trouble with accuracy.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions