简体   繁体   English

SQL Server Reporting Services四舍五入到小数位数后的舍入

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

I need to do some very precise reporting in SQL Server Reporting Services. 我需要在SQL Server Reporting Services中进行一些非常精确的报告。 I'm actually attempting to show 13 decimal places. 我实际上是试图显示13位小数。 The odd part is even when I format the field C13, Reporting Services seems to round after an arbitrary number of total digits rather than anything to do with the format string. 奇怪的是,即使我格式化字段C13,Reporting Services似乎也会舍入任意数量的总位数,而不是与格式字符串有关。

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. 因此看来,我最终只能从源代码中得到15个实际数字。 Has anyone seen this before, or know how to resolve it? 有没有人看过这个,或者知道如何解决?

It sounds to me like you are using the Float datatype. 在我看来,您正在使用Float数据类型。 Instead, I would suggest you use the decimal data type instead. 相反,我建议您改用十进制数据类型。 You'll probably want to use something like Decimal(20, 14). 您可能需要使用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. 您仍然需要对执行的数学非常小心,因为当您对小数执行数学运算时,SQL Server会修改结果数据类型。

Actually, I found the problem was Microsoft's Double.ToString() method. 实际上,我发现问题出在微软的Double.ToString()方法上。 I had to use a "G13" as a formatting string to get all of the decimal places. 我必须使用“ G13”作为格式字符串来获取所有小数位。 Go figure. 去搞清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM