Renames the Cos function (which is in Radian) to CosR and defines Cos in Degrees
ID: 48
See: Rename
using uCalcSoftware;
var uc = new uCalc();
uc.DefineConstant("pi = Atan(1) * 4");
// Original Cosine behavior with Radian
Console.WriteLine(uc.EvalStr("Cos(pi)"));
Console.WriteLine(uc.EvalStr("Cos(180)"));
// Cos is renamed to CosR so that Cos can now be defined in Degree
uc.ItemOf("Cos").Rename("CosR");
uc.DefineFunction("Cos(x) = CosR(x*pi/180)");
// Now Cos is in Degree
Console.WriteLine(uc.EvalStr("Cos(pi)"));
Console.WriteLine(uc.EvalStr("Cos(180)"));
// This is the original function now named CosR
Console.WriteLine(uc.EvalStr("CosR(pi)"));
Console.WriteLine(uc.EvalStr("CosR(180)"));
// Note: Some functions may be overloaded, such as the Cos function in
// this example, which has a definition for Double and another for Complex.
// This example renames only the Double precision version.
// You can use NextOverload() and DataType() to pinpoint the one you want
-1
-0.59846006905785
0.99849714986386
-1
-1
-0.59846006905785 using uCalcSoftware; var uc = new uCalc(); uc.DefineConstant("pi = Atan(1) * 4"); // Original Cosine behavior with Radian Console.WriteLine(uc.EvalStr("Cos(pi)")); Console.WriteLine(uc.EvalStr("Cos(180)")); // Cos is renamed to CosR so that Cos can now be defined in Degree uc.ItemOf("Cos").Rename("CosR"); uc.DefineFunction("Cos(x) = CosR(x*pi/180)"); // Now Cos is in Degree Console.WriteLine(uc.EvalStr("Cos(pi)")); Console.WriteLine(uc.EvalStr("Cos(180)")); // This is the original function now named CosR Console.WriteLine(uc.EvalStr("CosR(pi)")); Console.WriteLine(uc.EvalStr("CosR(180)")); // Note: Some functions may be overloaded, such as the Cos function in // this example, which has a definition for Double and another for Complex. // This example renames only the Double precision version. // You can use NextOverload() and DataType() to pinpoint the one you want
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uc.DefineConstant("pi = Atan(1) * 4");
// Original Cosine behavior with Radian
cout << uc.EvalStr("Cos(pi)") << endl;
cout << uc.EvalStr("Cos(180)") << endl;
// Cos is renamed to CosR so that Cos can now be defined in Degree
uc.ItemOf("Cos").Rename("CosR");
uc.DefineFunction("Cos(x) = CosR(x*pi/180)");
// Now Cos is in Degree
cout << uc.EvalStr("Cos(pi)") << endl;
cout << uc.EvalStr("Cos(180)") << endl;
// This is the original function now named CosR
cout << uc.EvalStr("CosR(pi)") << endl;
cout << uc.EvalStr("CosR(180)") << endl;
// Note: Some functions may be overloaded, such as the Cos function in
// this example, which has a definition for Double and another for Complex.
// This example renames only the Double precision version.
// You can use NextOverload() and DataType() to pinpoint the one you want
}
-1
-0.59846006905785
0.99849714986386
-1
-1
-0.59846006905785 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uc.DefineConstant("pi = Atan(1) * 4"); // Original Cosine behavior with Radian cout << uc.EvalStr("Cos(pi)") << endl; cout << uc.EvalStr("Cos(180)") << endl; // Cos is renamed to CosR so that Cos can now be defined in Degree uc.ItemOf("Cos").Rename("CosR"); uc.DefineFunction("Cos(x) = CosR(x*pi/180)"); // Now Cos is in Degree cout << uc.EvalStr("Cos(pi)") << endl; cout << uc.EvalStr("Cos(180)") << endl; // This is the original function now named CosR cout << uc.EvalStr("CosR(pi)") << endl; cout << uc.EvalStr("CosR(180)") << endl; // Note: Some functions may be overloaded, such as the Cos function in // this example, which has a definition for Double and another for Complex. // This example renames only the Double precision version. // You can use NextOverload() and DataType() to pinpoint the one you want }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
uc.DefineConstant("pi = Atan(1) * 4")
'// Original Cosine behavior with Radian
Console.WriteLine(uc.EvalStr("Cos(pi)"))
Console.WriteLine(uc.EvalStr("Cos(180)"))
'// Cos is renamed to CosR so that Cos can now be defined in Degree
uc.ItemOf("Cos").Rename("CosR")
uc.DefineFunction("Cos(x) = CosR(x*pi/180)")
'// Now Cos is in Degree
Console.WriteLine(uc.EvalStr("Cos(pi)"))
Console.WriteLine(uc.EvalStr("Cos(180)"))
'// This is the original function now named CosR
Console.WriteLine(uc.EvalStr("CosR(pi)"))
Console.WriteLine(uc.EvalStr("CosR(180)"))
'// Note: Some functions may be overloaded, such as the Cos function in
'// this example, which has a definition for Double and another for Complex.
'// This example renames only the Double precision version.
'// You can use NextOverload() and DataType() to pinpoint the one you want
End Sub
End Module
-1
-0.59846006905785
0.99849714986386
-1
-1
-0.59846006905785 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() uc.DefineConstant("pi = Atan(1) * 4") '// Original Cosine behavior with Radian Console.WriteLine(uc.EvalStr("Cos(pi)")) Console.WriteLine(uc.EvalStr("Cos(180)")) '// Cos is renamed to CosR so that Cos can now be defined in Degree uc.ItemOf("Cos").Rename("CosR") uc.DefineFunction("Cos(x) = CosR(x*pi/180)") '// Now Cos is in Degree Console.WriteLine(uc.EvalStr("Cos(pi)")) Console.WriteLine(uc.EvalStr("Cos(180)")) '// This is the original function now named CosR Console.WriteLine(uc.EvalStr("CosR(pi)")) Console.WriteLine(uc.EvalStr("CosR(180)")) '// Note: Some functions may be overloaded, such as the Cos function in '// this example, which has a definition for Double and another for Complex. '// This example renames only the Double precision version. '// You can use NextOverload() and DataType() to pinpoint the one you want End Sub End Module