⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 operation.java

📁 手机在线系统 采用Java 中的J2ME, JSP 跟MySql 运行环境是:jsdk1.4以上
💻 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 + -