Microsoft KB Archive/154000

= PRB: STR Inconsistent with Exact Numeric Data =

Article ID: 154000

Article Last Modified on 3/16/2005

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition
 * Microsoft SQL Server 6.0 Standard Edition
 * Microsoft SQL Server 6.5 Standard Edition
 * Microsoft SQL Server 7.0 Standard Edition

-



This article was previously published under Q154000





SYMPTOMS
The first parameter of the STR function is float. Numeric data passed as the first parameter to the STR function is first converted to float and then rounded.



STATUS
This is by design.



MORE INFORMATION
The following example demonstrates this scenario: declare @x1 numeric(8,6), @x2 numeric(8,6) select @x1 = 12.104375, @x2 = 12.128175

select str(@x1, 9, 5) STR, round(@x1, 5) ROUND select str(@x2, 9, 5) STR, round(@x2, 5) ROUND The @x1 numeric value 12.104375 is first converted to float 12.104374999999999. The STR function then rounds the fractional part of the number to the decimal you specified. In this example, STR rounds 12.104374999999999 to 12.10437 (5 decimal places).

The @x2 numeric value 12.128175 is first converted to float 12.128175000000001. Then, STR rounds 12.128175000000001 to 12.12818 (5 decimal places).

See SQL Server Books Online topic "STR".

Keywords: kbbug kbprb KB154000

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.