开发者

SQL Server Reporting Services Rounding after a set number of decimal places

开发者 https://www.devze.com 2023-02-06 02:08 出处:网络
I need to do some very precise reporting in SQL Server Reporting Services.I\'m actually attempting to show 13 decimal places.The odd part is even when I format the field C13, Repo开发者_如何转开发rtin

I need to do some very precise reporting in SQL Server Reporting Services. I'm actually attempting to show 13 decimal places. The odd part is even when I format the field C13, Repo开发者_如何转开发rting Services seems to round after an arbitrary number of total digits rather than anything to do with the format string.

For example if I have:
1000.01234567890123

What I end up with is:
1000.0123456789000

If on the other hand I have:
10.01234567890123

What I end up with is:
10.01234567890100

So it appears that I only end up with 15 actual digits from my source number. Has anyone seen this before, or know how to resolve it?


It sounds to me like you are using the Float datatype. Instead, I would suggest you use the decimal data type instead. You'll probably want to use something like Decimal(20, 14). You'll still need to be very careful about the math you perform because SQL Server will modify the resulting data type when you perform math on decimals.


Actually, I found the problem was Microsoft's Double.ToString() method. I had to use a "G13" as a formatting string to get all of the decimal places. Go figure.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号