我需要将十进制数格式化为货币,但我不希望在此过程中进行任何舍入。
例如(示例文化是 en-US)
Dim money = 1234.556789D
money.ToString("C") ' Yields $1,234.56 (notice the rounding & truncating)
money.ToString("C99") ' Yields $1,234.556789000000000000....0 -- close but not perfect, those trailing zeros are unwanted.
' I want something that would result in this...
money.ToString("??") ' Yields $1,234.56789
' likewise....
money = 0.1D
money.ToString("??") ' Yields $0.10 (notice that it at least matches the culture's currency format -- two decimal places)
假设此应用程序的所有用户都将使用 en_US 规则,我可以将其设为“??” 是一些硬编码的东西,比如 "$#,##0.00##################################### ###########################”——但这让我的胃翻腾。有没有一种内置的方法来完成我所追求的?