如果它與數字 .4 交叉,我想讓代碼對數字進行四舍五入 例如 2.4 = 2, 2.5 = 3 也就是說,它不會四舍五入到 4,而是在四舍五入之后
uj5u.com熱心網友回復:
使用MidpointRounding.AwayFromZero附加引數:
[Math]::Round(2.5, [MidpointRounding]::AwayFromZero) # 3
[Math]::Round(0.5, [MidpointRounding]::AwayFromZero) # 1
[Math]::Round(2.49, [MidpointRounding]::AwayFromZero) # 2, because 2.49 is not midpoint
默認情況下,如果未指定則[Math]::Round使用。[MidpointRounding]::ToEven
有關詳細資訊,請參閱檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/517249.html
標籤:电源外壳
