Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pug2694328
Posting Yak Master
166 Posts |
Posted - 2006-04-18 : 11:39:33
|
| When pulling REAL formatted numeric data using the ROUND() function, I'm seeing unexpected amts in output when the thousandths place is a 5. Any ideas?Example:TABLEPRCES: Composite PricingClose_ realQUERYSELECT ROUND(PRCES.CLOSE_,2) AS ROUNDED_CLOSE , PRCES.CLOSE_FROM PRCESOUTPUTROUNDED_CLOSE CLOSE_70.0 70.070.0 70.069.629999999999995 69.62569.5 69.570.0 70.068.629999999999995 68.625I've tried to reproduce this using transact SQL, but can't:DECLARE @SOMENUM REALSET @SOMENUM = 69.625PRINT ROUND(@SOMENUM,2)OUTPUT69.63Thanks in advance! |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-04-18 : 11:52:00
|
| It converts 69.625 to 2 dec places = 69.63It outputs that as a real as PRCES.CLOSE_ is a a real.69.23 cannot be represented exactly as a real so 69.629999999999995 tryselect round(convert(real, 69.625),2)select round(69.625,2)select convert(real,69.625)select convert(real,69.63)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
pug2694328
Posting Yak Master
166 Posts |
Posted - 2006-04-18 : 16:35:02
|
| Oddest thing... when run in the SQL Server 2005, the problem goes away.So was this a bug that was corrected or was 2000 mathematically correct and they fudge it for 2005 because the reinterpretation was not practical? |
 |
|
|
|
|
|