取值范围

Posted thekiterunner

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了取值范围相关的知识,希望对你有一定的参考价值。

// 扩大范围 向上取整
function ceilRange(temperature) {
    var tem;
    if (temperature > 0) {
        return Math.ceil(temperature * 1.2);
    }
    if (temperature < 0) {
        return Math.ceil(temperature * 0.8);
    }
    if (temperature == 0) {
        return 0;
    }
}

//扩大范围 向下取整
function floorRange(temperature) {
    if (temperature > 0) {
        return Math.floor(temperature * 0.8);
    }
    if (temperature < 0) {
        return Math.floor(temperature * 1.2);
    }
    if (temperature == 0) {
        return 0;
    }
}

 

以上是关于取值范围的主要内容,如果未能解决你的问题,请参考以下文章