zoukankan      html  css  js  c++  java
  • 数值的比较

        /**
         * 比较两个Ineger 数值的大小 返回最小值和最大值
         */
        public static Integer[] compareSize(Integer str1, Integer str2, Integer str3, Integer str4) {
    
            Integer a[] = new Integer[]{str1, str2, str3, str4};
            for (int i = 0; i < a.length; i++) {
                for (int j = 0; j < a.length; j++) {
                    if (a[i] < a[j]) { //由小到大 第一个最小,最后一个最大
                        int b = a[i];
                        a[i] = a[j];
                        a[j] = b;
                    }
                }
            }
    
            return a;
        }
    
        /**
         * 比较四个double类型数字的最大值和最小值
         */
    
        public static double getThreeMax(double a,double b ,double c ,double d){
            double max=a>b ? a : b;
            max=max > c ? max :c ;
            max=max > d ? max :d ;
            return max;
        }
    
    
        /**
         * 比较四个double类型数字的最小值
         */
    
        public static double getThreeMix(double a,double b ,double c ,double d){
            double min=a<b ? a : b;
            min=min < c ? min :c ;
            min=min < d ? min :d ;
            return min;
        }
    
    
    
        /**
         * 判断当前时间是否在指定的时间区间范围
         *
         * @param nowTime
         * @param start
         * @param end
         * @return
         */
        public static Boolean isEffectiveDate(Double nowTime, Double start, Double end) {
    
            if (nowTime.compareTo(start) >= 0 && nowTime.compareTo(end) <= 0) {
                return true;
            } else {
                return false;
            }
        }
    
        /**
         * 当前时间的最小值和指定区间的最大时间相比如果大于区间最大时间 则返回true
         */
    
        public static Boolean compareMinSize(Double mix, Double end) {
    
            if (mix.compareTo(end) > 0) {
                return true;
            }
            return false;
        }
    
        /**
         * 当前时间的最大值和指定区间的最小时间相比如果小于区间最小时间 则返回true
         */
    
        public static Boolean compareMaxSize(Double max, Double start) {
    
            if (max.compareTo(start) < 0) {
                return true;
            }
            return false;
    
        }
  • 相关阅读:
    Verilog语言
    OrCAD --从SNAPEDA导入封装库
    RAM/ROM IP一次性总结
    USB之Main item, Local item和Global item 的作用范围与归类
    发光LED压降与工作电流总结
    C之输入输出函数(3) -- 请使用sscanf()
    C之输入输出函数(2) -- gets()
    C之输入输出函数(1) -- fgets()
    C中的lvalue和rvalue
    关于字符串的一点补充
  • 原文地址:https://www.cnblogs.com/JonaLin/p/11240210.html
Copyright © 2011-2022 走看看