views:

596

answers:

2

Hui folks,

I need to be able to store numbers like 3.5 in my table. So I've used the decimal type field. But if I enter 3.5 it round it up to 4. Am I being stupid or is it not the point of decimal to have a decimal point?

Thanks,

Jonesy

A: 

Why you do not use FLOAT,

And if You need to round always numbers to 0.0 or 0.5 take look at this thread

adopilot
yup that worked, I just though FLOAT was for massive numbers. Thinks I need to get my head around data types again. thanks adopilot!
iamjonesy
@Jonesy - just make sure you understand the difference between FLOATs and DECIMALs as they are not the same. FLOAT is approximate: http://msdn.microsoft.com/en-us/library/ms173773.aspx vs DECIMAL reference: http://msdn.microsoft.com/en-us/library/ms187746.aspx
AdaTheDev
Float is a very bad idea if you plan to do math onthe value. It will cause rounding errors as it is not an exact value. Very bad recommendation.
HLGEM
A: 

how you defined decimal? you need to declare it like decimal(18,3) - and 3 means number of digits after point

Sergey Osypchuk
yeah it was declared as decimal(18,3). Not sure why I rounded it.
iamjonesy
How did you put data?Maybe you are using stored procedure - than parameter also should have type decimal(18,3), not just decimal.
Sergey Osypchuk