zoukankan      html  css  js  c++  java
  • 数学运算类(三角函数,取整函数,指数函数,取最大值,最小值,绝对值)

    package com.lei.duixiang;
    
    public class ExponentFunction {
    
        /**
         * 数学运算类
         * 1.三角函数
         * 2.指数函数
         * 3.取整函数
         * 4.取最大值,最小值,绝对值函数
         * @param args
         */
        // 1. 三角函数方法
        static public void SanJiao(){
            //取 90 度的正弦
            System.out.println("90度的正弦值:"+Math.sin(Math.PI / 2));
            System.out.println(" 0 度的余弦值:"+Math.cos(0));    //取 0 度的余弦
            //取 60 度的正切
            System.out.println("60 度的正切值:"+Math.tan(Math.PI / 3));
            //取2 的平方根与 2商的反正弦
            System.out.println("2 的平方根与 2商的反正弦 :"+Math.asin(Math.sqrt(2)/2));
            //取2 的平方根与 2商的反余弦
            System.out.println("2 的平方根与 2商的反余弦 :"+Math.acos(Math.sqrt(2)/2));
            System.out.println("1 的反正切值:"+Math.atan(1));    //取 1 的反正切
            //取 120 度的弧度值
            System.out.println("120度的弧度值:"+Math.toRadians(120.0));
            //取∏/2 的角度
            System.out.println("∏/2的角度值:"+Math.toDegrees(Math.PI / 2));
            System.out.println("----------------------");
        }
        
        // 2. 指数函数方法
        static public void Zhishu(){
            System.out.println("e 的平方值:"+Math.exp(2));    //取e的二次方
            //取 以 e为底2 的对数
            System.out.println("取 以 e为底2 的对数值:"+Math.log(2));
            //取 以 10为底2 的对数
            System.out.println("取以 10为底2 的对数值:"+Math.log10(2));
            System.out.println("4 的平方根值:"+Math.sqrt(4));//取4的平方根
            System.out.println("8 的立方根值:"+Math.cbrt(8));//取8的立方根
            System.out.println("2 的2次方值:"+Math.pow(2,2));//取2的2次方根
            System.out.println("-------------------");
        }
        
        //3.取整函数方法
        static public void QuZheng(){
            //返回第一个大于参数的整数
            System.out.println("使用 ceil() 方法取整:"+Math.ceil(5.2));
            //返回第一个小于参数的整数
            System.out.println("使用 floor() 方法取整:"+Math.floor(2.5));
    
            //返回与参数最接近的整数
            System.out.println("使用 rint() 方法取整:"+Math.rint(2.7));
            //返回与参数最接近的整数
            System.out.println("使用rint() 方法取整:"+Math.rint(2.5));
            //将参数加上0.5后返回最接近的整数
            System.out.println("使用 round () 的方法取整:"+ Math.round(3.4f));
            //将参数加上0.5后返回最接近的整数,并将结果强制转换为长整型
            System.out.println("使用 round() 方法取整:"+Math.round(2.5));
            System.out.println("--------------------------");
            
        }
        //4.取最大值,最小值,绝对值函数
        static public void QuMaxMin(){
            System.out.println(" 4 和 8 较大者:"+Math.max(4, 8));
            //取 2 个参数的最小值
            System.out.println("4.4 和 4 较小者:"+Math.min(4.4, 4));
            System.out.println("-7 的绝对值:"+Math.abs(-7));
            System.out.println("--------------------");
        }
        
        public static void main(String[] args) {
            SanJiao(); // 1. 三角函数方法
            Zhishu();// 2. 指数函数方法
            QuZheng();//3.取整函数方法
            QuMaxMin();//4.取最大值,最小值,绝对值函数
        }
    
    }
  • 相关阅读:
    vue中的 computed 和 watch 的区别
    mysql8.0 初始化数据库及表名大小写问题
    sql server alwayson 调整数据文件路径
    zabbix 自定义监控 SQL Server
    mysql 创建用户及授权
    mysql 设置从库只读模式
    mysql8.0 主从复制安装及配置
    centos8.0安装mysql8.0
    centos8替换阿里数据源
    npm publish 报错 【you or one of your dependencies are requesting a package version that is forbidden by your security policy】
  • 原文地址:https://www.cnblogs.com/spadd/p/4169817.html
Copyright © 2011-2022 走看看