Дзюндзя ([info]syarzhuk) wrote,
@ 2006-04-13 11:01:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Entry tags:code, sql

SQL Server stinks!
SELECT Round(59999.0 * 0.155,2)
9299.8500 - correct

SELECT Round(Cast(59999.0 as money) * Cast(0.155 as float),2)
9299.8400000000001 - wrong!

Fix:
SELECT Round(Cast(Cast(59999.0 as money) * Cast(0.155 as float) as money) ,2)




(Post a new comment)


[info]irrra
2006-04-13 03:39 pm UTC (link)
Задолбаешься ж потом дебагить...

(Reply to this) (Thread)


[info]syarzhuk
2006-04-13 03:43 pm UTC (link)
Лучше лишний каст, чем потерянный цент

(Reply to this) (Parent)


Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…