📄 operator.java
字号:
package HECore.stddata;
import java.lang.*;
import HPCore.Exception.*;
public class Operator {
public static short Add(short i,short j)
{
return (short)(i+j);
}
public static int Add(int i,int j)
{
return i+j;
}
public static float Add(float i,float j)
{
return i+j;
}
public static double Add(double i,double j)
{
return i+j;
}
public static String Add(String i,String j) throws HpException
{
if(i == null)
i = "";
if(j == null)
j = "";
return i + j;
}
/********************* Sub *********************************/
/***********************************************************/
public static short Sub(short i,short j)
{
return (short)(i-j);
}
public static int Sub(int i,int j)
{
return i-j;
}
public static float Sub(float i,float j)
{
return i-j;
}
public static double Sub(double i,double j)
{
return i-j;
}
public static double Sub(String i,String j) throws HpException
{
return convert.str2dbl(i)-convert.str2dbl(j);
}
public static short Mult(short i,short j)
{
return (short)(i*j);
}
public static int Mult(int i,int j)
{
return i*j;
}
public static float Mult(float i,float j)
{
return i*j;
}
public static double Mult(double i,double j)
{
return i*j;
}
public static double Mult(String i,String j) throws HpException
{
return convert.str2dbl(i)*convert.str2dbl(j);
}
/****************************Div *****************************/
/**************************************************************/
public static short Div(short i,short j) throws HpException
{
if(j==0)
throw new HpException(11,"Division by zero");
return (short)(i/j);
}
public static int Div(int i,int j) throws HpException
{
if(j==0)
throw new HpException(11,"Division by zero");
return i/j;
}
public static float Div(float i,float j) throws HpException
{
if(j==0)
throw new HpException(11,"Division by zero");
return (float)(i/j);
}
public static double Div(double i,double j) throws HpException
{
if(j==0)
throw new HpException(11,"Division by zero");
return (double)(i/j);
}
public static double Div(String i,String j) throws HpException
{
if(convert.str2dbl(j)==0)
throw new HpException(11,"Division by zero");
return convert.str2dbl(i)/convert.str2dbl(j);
}
public static short DDiv(short i,short j) throws HpException
{
if(j==0)
throw new HpException(11,"Division by zero");
return (short)(i/j);
}
public static int DDiv(int i,int j) throws HpException
{
if(j==0)
throw new HpException(11,"Division by zero");
return i/j;
}
public static int DDiv(float i,float j) throws HpException
{
if(j==0)
throw new HpException(11,"Division by zero");
return (int)(i/j);
}
public static int DDiv(double i,double j) throws HpException
{
if(j==0)
throw new HpException(11,"Division by zero");
return (int)(i/j);
}
public static int DDiv(String i,String j) throws HpException
{
if(convert.str2dbl(j)==0)
throw new HpException(11,"Division by zero");
return(int)( convert.str2dbl(i)/convert.str2dbl(j));
}
public static int DDiv(Variant i,Variant j) throws HpException
{
if(j.dblValue()==0.0)
throw new HpException(11,"Division by zero");
return(int)(i.dblValue()/j.dblValue());
}
public static int And(int a,int b)
{
int value = a & b;
return value;
}
public static int And(double a,double b)
{
int value = (int)a & (int)b;
return value;
}
public static int And(String a,String b) throws HpException
{
int value = (int)convert.str2dbl(a) & (int)convert.str2dbl(b);
return value;
}
/*************************** Or ************************/
/********************************************************/
/**
Returns a Variant whose value is (this | b)
**/
public static int Or(int a,int b)
{
int value = a | b;
return value;
}
public static int Or(double a,double b)
{
int value = (int)a | (int)b;
return value;
}
public static int Or(String a,String b) throws HpException
{
int value = (int)convert.str2dbl(a) |(int)convert.str2dbl(b);
return value;
}
public static int Xor(int a,int b)
{
int value = a ^ b;
return value;
}
public static int Xor(double a,double b)
{
int value = (int)a ^ (int)b;
return value;
}
public static int Xor(String a,String b) throws HpException
{
int value = (int)convert.str2dbl(a) ^ (int)convert.str2dbl(b);
return value;
}
/**
Used to perform a logical implication on two expressions.
Returns a Variant whose value is (~this & ~b)
**/
public static int Imp(int a,int b)
{
int value = ~(a & (~b));
return value;
}
public static int Imp(double a,double b)
{
int value = ~((int)a & (~(int)b));
return value;
}
public static int Imp(String a,String b) throws HpException
{
int value = ~((int)convert.str2dbl(a) & (~(int)convert.str2dbl(b)));
return value;
}
public static double Pow(short a,short b)
{
double value = Math.pow((double)a,(double)b);
return value;
}
public static double Pow(int a,int b)
{
double value = Math.pow((double)a,(double)b);
return value;
}
public static double Pow(float a,float b)
{
double value = Math.pow((double)a,(double)b);
return value;
}
public static double Pow(double a,double b)
{
double value = Math.pow((double)a,(double)b);
return value;
}
public static double Pow(String a,String b) throws HpException
{
double value = Math.pow(new VString(a).dblValue(),new VString(b).dblValue());
return value;
}
public static double Pow(Variant a,Variant b) throws HpException
{
double value = (double)Math.pow(a.dblValue(),b.dblValue());
return value;
}
/** Comparison Operators ----Mod
**/
public double Mod(short a,short b) throws HpException
{
if(b ==0)
throw new HpException(11,"Division by Zero.");
double value = (double)((int)a % (int)b);
return value;
}
public double Mod(int a,int b) throws HpException
{
if(b ==0)
throw new HpException(11,"Division by Zero.");
double value = (double)(a % b);
return value;
}
public double Mod(float a,float b) throws HpException
{
if(b ==0.0 )
throw new HpException(11,"Division by Zero.");
double value = (double)((int)a % (int)b);
return value;
}
public double Mod(double a,double b) throws HpException
{
if(b ==0.0 )
throw new HpException(11,"Division by Zero.");
double value = (double)((int)a % (int)b);
return value;
}
public double Mod(String a,String b) throws HpException
{
if(b.equals("0.0") )
throw new HpException(11,"Division by Zero.");
double value = (double)((int)(new VString(a).dblValue()) % (int)(new VString(b).dblValue()));
return value;
}
public double Mod(Variant a,Variant b) throws HpException
{
if(b.dblValue() ==0.0 )
throw new HpException(11,"Division by Zero.");
double value = (double)((int)a.dblValue() % (int)b.dblValue());
return value;
}
public static boolean Eqv(int a,int b)
{
int value = (~(a ^ b));
if(value==0)
return false;
else
return true;
}
public static boolean Eqv(float a,float b)
{
int value = (~((int)a ^ (int)b));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -