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 |
|
Aleph_0
Yak Posting Veteran
79 Posts |
Posted - 2011-04-29 : 11:43:55
|
| Hi again, I'm having a little trouble understanding the difference between a decimal and a float. From what I understand, floats are rounded, so does that mean decimals are truncated?If I'm calculating medians of integers less than 1000, which should I use? I'm thinking float since it takes up less storage, and also since the medians will always be integers or have only a .5 decimal place (so I shouldn't have to worry about the rounding, right?). Am I on the right track here?Thank you! |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-04-29 : 11:53:48
|
| floats are approximate values whereas decimals are accurate.In your cse I would go for a decimal.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-04-29 : 11:54:45
|
| You could go with either and probably wouldn't make much of a difference in practical terms. But, I would probably pick decimal - it would be precise. Use decimal (5,1) - that is 5 digits all together, with one reserved for decimal part. As for storage, you would use up 5 bytes for decimal and 4 for float. |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-04-29 : 11:55:53
|
I seem to be getting shot at a lot today!! I am not going to post anything more today, I promise!! |
 |
|
|
Aleph_0
Yak Posting Veteran
79 Posts |
Posted - 2011-04-29 : 12:11:42
|
| Yeah, I figured there wasn't a dramatic difference. Thanks. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|
|