C# 小數點無條件捨去 Published on: 2020-11-082020-11-08Author: NelsonComment: 0 常常在顯示面需要回傳小數點無條件捨去 書到用時方恨少, 因此紀錄兩種做法 // 取小數點2位(無條件捨去) Decimal result = Math.Floor(123.123456 * 100) / 100; // output: 123.12 // 小數4位 (無條件捨去) Decimal result = decimal.Truncate(123.123456 * 10000) / 10000; // output: 123.1234 留言 文章導覽 Previous PostC# 使用快取記憶體(Runtime.Caching)降低資料庫I/ONext Post低利率時代信貸投資有利可圖? 投資型保單? ETF?