第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何舍入到最接近的0.5?

如何舍入到最接近的0.5?

慕絲7291255 2019-11-29 15:46:37
我必須顯示收視率,為此,我需要增加如下值:如果數(shù)字是1.0,則應(yīng)等于1;如果數(shù)字是1.1,則應(yīng)等于1;如果數(shù)字是1.2,則應(yīng)等于1;如果數(shù)字是1.3,則應(yīng)等于1.5;如果數(shù)字是1.4,則應(yīng)等于1.5如果數(shù)字為1.5,則應(yīng)等于1.5;如果數(shù)字為1.6,則應(yīng)等于1.5;如果數(shù)字為1.7,則應(yīng)等于1.5;如果數(shù)字為1.8,則應(yīng)等于2.0;如果數(shù)字是1.9,則應(yīng)等于2.0如果數(shù)字為2.0應(yīng)等于2.0如果數(shù)字為2.1應(yīng)等于2.0依此類推...是否有一種簡(jiǎn)單的方法來(lái)計(jì)算所需的值?
查看完整描述

3 回答

?
aluckdog

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超7個(gè)贊

將您的評(píng)分乘以2,然后使用舍入Math.Round(rating, MidpointRounding.AwayFromZero),然后將該值除以2。


Math.Round(value * 2, MidpointRounding.AwayFromZero) / 2



查看完整回答
反對(duì) 回復(fù) 2019-11-29
?
蠱毒傳說(shuō)

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超3個(gè)贊

乘以2,取整,然后除以2


如果要最近的四分之一,請(qǐng)乘以4,再除以4,以此類推


查看完整回答
反對(duì) 回復(fù) 2019-11-29
?
收到一只叮咚

TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超5個(gè)贊

這是我編寫(xiě)的幾種方法,它們總是可以向上或向下舍入為任何值。


public static Double RoundUpToNearest(Double passednumber, Double roundto)

{

    // 105.5 up to nearest 1 = 106

    // 105.5 up to nearest 10 = 110

    // 105.5 up to nearest 7 = 112

    // 105.5 up to nearest 100 = 200

    // 105.5 up to nearest 0.2 = 105.6

    // 105.5 up to nearest 0.3 = 105.6


    //if no rounto then just pass original number back

    if (roundto == 0)

    {

        return passednumber;

    }

    else

    {

        return Math.Ceiling(passednumber / roundto) * roundto;

    }

}


public static Double RoundDownToNearest(Double passednumber, Double roundto)

{

    // 105.5 down to nearest 1 = 105

    // 105.5 down to nearest 10 = 100

    // 105.5 down to nearest 7 = 105

    // 105.5 down to nearest 100 = 100

    // 105.5 down to nearest 0.2 = 105.4

    // 105.5 down to nearest 0.3 = 105.3


    //if no rounto then just pass original number back

    if (roundto == 0)

    {

        return passednumber;

    }

    else

    {

        return Math.Floor(passednumber / roundto) * roundto;

    }

}


查看完整回答
反對(duì) 回復(fù) 2019-11-29
  • 3 回答
  • 0 關(guān)注
  • 1498 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)