Skip to content

Instantly share code, notes, and snippets.

@ryepup
Created February 10, 2015 14:20
Show Gist options
  • Save ryepup/53d677c4021ce46c16c7 to your computer and use it in GitHub Desktop.
Save ryepup/53d677c4021ce46c16c7 to your computer and use it in GitHub Desktop.
fun with rounding and data types
DECLARE @x money, @t money
SET @x = 15062.53
SET @t = 51679.61
SELECT
15062.53/51679.61,
-- 0.2914598233
@x / @t,
-- 0.2914
CAST(@x as decimal) / @t,
-- 0.2914667182662538699
CAST(@x as decimal) / CAST(@t as decimal),
-- 0.2914689178188457
CAST(@x as float) / @t,
-- 0.29145982332297
CAST(@x as float) / CAST(@t as float)
-- 0.29145982332297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment