You are of course right, as is Richard. Using integers for currency (working in cents) is a very old school way of dealing with performance issues of numeric data type. Basically any operation on numeric is (was?) much more expensive than floats or integers. These days it's not such an issue anymore.
And yes I have written financial type applications which needed to account for fractions of a cent. These generally involved share trading and/or foreign currency conversions. I also wonder if that was a some sort of regulatory/accounting requirement or the fact that SQL Server money type is a numeric with a precision of 4... dali > Unless of course your accounting in fractions of cents (which does happen > quite a lot) > > Neven > > : > >> On Apr 21, 5:38 pm, Richard Clark <[email protected]> wrote: > >> > >>> 2. Don't use floating point numbers to manage currency. They're they > >>> lossy compression of numerics and you can end up with some > >>> unpleasant surprises. > >>> > >> I.e. > >> > >> if (0.1 + 0.2 == 0.3) > >> echo "Roger roger"; > >> else > >> echo "WAT?!"; > >> > >> >> WAT?! > >> > > > > Or you can bypass the whole issue by working in cents :-) > > > > dali > > > > > > -- > NZ PHP Users Group: http://groups.google.com/group/nzphpug > To post, send email to [email protected] To unsubscribe, send > email to > [email protected] -- NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected]
