[英]How to generate a random number with 8 digits total in C#? (4 integer, 4 fractional part)
[英]How to round with fractional digits in C#?
如何在逗號后四舍五入兩位數?
Ex: I have a 3,7512 . I need 3,76 .
那對你有用嗎?
double value = 0.01 * Math.Ceiling(100.0 * originalValue)
使用Math.Round方法。 它接受第二個參數,該參數確定要舍入的小數位數。
Math.Round(3.7512, 2) // this rounds up to 3.75
Math.Round(3.7572, 2) // this rounds up to 3.76
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.