我有需要格式化十进制数字作为货币,但我不希望任何舍入过程中发生。格式货币没有舍入
例如(例如文化是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 ##################################### ###########################“ - 但是这会让我的胃流失。有没有内置的方式来完成我后?
我已经浏览了大约20分钟的帮助文档,但什么都没发现。抱歉。 – Greg 2009-07-24 21:54:04
我很感谢你的时间格雷格。对不起,搜索离开了你(和我)空手。我想这样的需求并不是非常“正常”,这意味着框架不会自然地运用这个功能。哦,如下所述,我结束了我自己的解决方案,直到微软认为它将非常棒/足够用于烧入框架;) – ckittel 2009-07-26 19:12:11