> I think it's a bad idea doing that. you can display the value with two
> decimal places but you should keep as many as it allows. Otherwise you
> can get into rounding problems when you operate in these values.
> > I think it's a bad idea doing that. you can display the value with two
> > decimal places but you should keep as many as it allows. Otherwise you
[quoted text clipped - 6 lines]
> wrong time (calculation) is what leads to the future rounding problems as
> you suggested.
I think I suggested exactly the opposite, do not do rounding in the
calculations (or in the storage of the values) only when you need to
display the value you should roundit.
Agree that the above is the general case, it might be cases where it
does not apply, IMHO those are the few.
> If Anodes business logic requires that he store a value with 2 decimal
> places in the database then rounding before the database operation takes
> place is the appropriate time. If not then not.
Of course, it for some reason the logic requires that, then by all
mean do it like that.
Most of the cases though that is not the case. and you can get nasty
side effects from it.
For example, if you are adding a large quantity of values you can get
a big difference.
Let's say that you have 1kk rows which "real" value is 10.0001, if
you round it to 10.00 when you sum all the rows you have a difference
of 100 !!!!
Arne Vajhøj - 14 Apr 2008 00:05 GMT
>>> I think it's a bad idea doing that. you can display the value with two
>>> decimal places but you should keep as many as it allows. Otherwise you
[quoted text clipped - 11 lines]
> Agree that the above is the general case, it might be cases where it
> does not apply, IMHO those are the few.
Decimal is mostly used for money.
My experience is the same as Gregg's: the business rules determine
when rounding should happen and it is not necessarily latest moment.
Rounding twice at different places in the calculations are also
sometimes seen.
For float and decimal I completely agree with you - round when
outputting. But accountants think differently.
Arne