Here you can find the source of clampToPercentageOrNAN(double input)
Parameter | Description |
---|---|
input | a percentage value |
public static double clampToPercentageOrNAN(double input)
//package com.java2s; public class Main { /**/*from w w w . j a v a2s.c om*/ * One hundred percent, as represented internally. */ public static final double ONE_HUNDRED_PERCENT_CPU_VALUE = 1.0; /** * @param input a percentage value * @return NaN if the value was NaN, 0% if <0%, 100% if >100%, otherwise the original value */ public static double clampToPercentageOrNAN(double input) { // apply fallbacks in case the input is invalid or "unusual" if (Double.isNaN(input)) { return Double.NaN; } else if (input < 0.0) { return 0.0; } else if (input > ONE_HUNDRED_PERCENT_CPU_VALUE) { return ONE_HUNDRED_PERCENT_CPU_VALUE; } else { return input; } } }