?? operation.java
字號:
/**
* @(#)Operation.java 1.11 01/08/23
* Copyright (c) 2004-2005 wuhua of workroom Inc. All Rights Reserved.
* @version 1.0, 10/05/2004
* @author 饒榮慶
* @author
*/
package com.j2me.counter;
/**
*類Operation是用來實現簡單的運算。
*/
public final class Operation
{
public static final double E = 2.7182818284590451D;
public static final double PI = 3.1415926535897931D;
private static long negativeZeroFloatBits = (long)Float.floatToIntBits(0F);
private static long negativeZeroDoubleBits = Double.doubleToLongBits(0D);
private Operation()
{
}
public static native double sin(double d);
public static native double cos(double d);
public static native double tan(double d);
public static native double sqrt(double d);
public static int abs(int a)
{
return a >= 0 ? a : -a;
}
public static long abs(long a)
{
return a >= 0L ? a : -a;
}
public static float abs(float a)
{
return a > 0.0F ? a : 0.0F - a;
}
public static double abs(double a)
{
return a > 0.0D ? a : 0.0D - a;
}
public static int max(int a, int b)
{
return a < b ? b : a;
}
public static long max(long a, long b)
{
return a < b ? b : a;
}
public static float max(float a, float b)
{
if(a != a)
{
return a;
}
if(a == 0.0F && b == 0.0F && (long)Float.floatToIntBits(a) == negativeZeroFloatBits)
{
return b;
} else
{
return a < b ? b : a;
}
}
public static double max(double a, double b)
{
if(a != a)
{
return a;
}
if(a == 0.0D && b == 0.0D && Double.doubleToLongBits(a) == negativeZeroDoubleBits)
{
return b;
} else
{
return a < b ? b : a;
}
}
public static int min(int a, int b)
{
return a > b ? b : a;
}
public static long min(long a, long b)
{
return a > b ? b : a;
}
public static float min(float a, float b)
{
if(a != a)
{
return a;
}
if(a == 0.0F && b == 0.0F && (long)Float.floatToIntBits(b) == negativeZeroFloatBits)
{
return b;
} else
{
return a > b ? b : a;
}
}
public static double min(double a, double b)
{
if(a != a)
{
return a;
}
if(a == 0.0D && b == 0.0D && Double.doubleToLongBits(b) == negativeZeroDoubleBits)
{
return b;
} else
{
return a > b ? b : a;
}
}
public static int add(int a, int b)
{
return a + b;
}
public static long add(long a, long b)
{
return a + b;
}
public static float add(float a, float b)
{
return a + b;
}
public static double add(double a, double b)
{
return a + b;
}
public static int minus(int a, int b)
{
return a - b;
}
public static long minus(long a, long b)
{
return a - b;
}
public static float minus(float a, float b)
{
return a - b;
}
public static double minus(double a, double b)
{
return a - b;
}
public static int multiply(int a, int b) //乘法運算
{
return a * b;
}
public static long multiply(long a, long b)
{
return a * b;
}
public static float multiply(float a, float b)
{
return a * b;
}
public static double multiply(double a, double b)
{
return a * b;
}
public static int division(int a, int b) //除法運算
throws ArithmeticException
{
if (b == 0)
{
new ArithmeticException();
}
return a / b;
}
public static long division(long a, long b)
throws ArithmeticException
{
if (b == 0L)
{
new ArithmeticException();
}
return a / b;
}
public static float division(float a, float b)
{
if (b == 0.0F)
{
new ArithmeticException();
}
return a / b;
}
public static double division(double a, double b)
{
if (b == 0.0D)
{
new ArithmeticException();
}
return a / b;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -