![]() ![]() | ||
Well, it may have been a mistake taking on that programming job from the astrophysics department. How do you calculate a hyperbolic cosecant anyway? Can Visual Basic do it? Yes, although not directly. The built-in Visual Basic math functions appear in Table 2.8-note that the old VB6 functions like Atn and Abs have been replaced by methods of the System.Math namespace.
Old |
New Visual Basic .NET method |
Description |
---|---|---|
Abs |
System.Math.Abs |
Yields the absolute value of a given number. |
Atn |
System.Math.Atan |
Yields a Double value containing the angle whose tangent is the given number. |
Cos |
System.Math.Cos |
Yields a Double value containing the cosine of the given angle. |
Exp |
System.Math.Exp |
Yields a Double value containing e (the base of natural logarithms) raised to the given power. |
Log |
System.Math.Log |
Yields a Double value containing the logarithm of a given number. |
Round |
System.Math.Round |
Yields a Double value containing the number nearest the given value. |
Sgn |
System.Math.Sign |
Yields an Integer value indicating the sign of a number. |
Sin |
System.Math.Sin |
Yields a Double value specifying the sine of an angle. |
Sqr |
System.Math.Sqrt |
Yields a Double value specifying the square root of a number. |
Tan |
System.Math.Tan |
Yields a Double value containing the tangent of an angle. |
To use these functions without qualification, import the System.Math namespace into your project. Here's an example that uses the Atan method:
Imports System.Math
Module Module1
Sub Main()
System.Console.WriteLine("Pi =" & 4 * Atan(1))
End Sub
End Module
And here's the result:
Pi =3.14159265358979 Press any key to continue
If what you want, like hyperbolic cosecant, is not in Table 2.8, try Table 2.9, which shows you how to calculate other results using the built-in Visual Basic functions. There's enough math power in Table 2.9 to keep most astrophysicists happy.
![]() ![]() | ||