In this link, we can see the source code of System.Math
class. But I cannot find the source code of how sine is defined.
Is there anything I am missing here?
The Math. sin() method in Javascript is used to return the sine of a number. The Math. sin() method returns a numeric value between -1 and 1, which represents the sine of the angle given in radians. The sin() is a static method of Math, therefore, it is always used as Math.
The signature of the method is:
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern double Sin(double a);
The extern
in the method means it is defined elsewhere. In this case, it will be implemented directly in the CLR (probably written in C or Assembly) which means there is no .NET implementation available.
You can't thought the .NET Framework source - it's an extern
function, meaning it's implemented in a lower-level library (probably the CLR itself, but I'm not certain).
You might try the Shared Source CLI
No you cannot see the source code of the sin function as its an extern function and embedded inside CLR. sine is implemented in microcode inside microprocessors, so this makes it really hard to check the implementation of the same as it may differ from platform to platform.
The extern modifier is used to declare a method that is implemented externally
And the sin function is declared as
public static extern double Sin(double x);
So it is not possible to see the source code for the sin function
I am not sure if this can be of any help but you may check the C version of the sin fucntion and also check sin function implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With