|
Posted by Bonge Boo! on 05/12/05 23:31
On 11/5/05 5:39 am, in article rmuge.745$bI7.474@news.get2net.dk, "Leif
Neland" <leifn@neland.dk> wrote:
>> Hope someone can clarify this. I have defined a table with some columns
>> that
>> are to carry pricing data as decimal numbers.
>>
>
>> `retail` decimal(4,2) NOT NULL default '0.00',
>> `buyprice` decimal(4,2) NOT NULL default '0.00',
>> `sell_ex` decimal(4,2) NOT NULL default '0.00',
>> `sell_inc` decimal(4,2) NOT NULL default '0.00',
>
>> However, when I import a load of tab-delimited data, I look through the
>> values and see that in a number of places the decimal column has values
>> like
>>
>> 72.95999999999999
>>
>> Now as I've specific the decimal precision I want, why the hell is that
>> happening? If I change the colum type to float the same thing happens.
>>
> Because some decimal fractions are impossible to store as binary fractions
> without rounding errors.
Ok. But the data I am inserting from a tab-delimited table is for example
72.60
Not 72.599999
> Therefore sometimes amounts are not stored as $/£/? with 2 decimals, but as
> cents/pence in integers.
I think I might have solved it. The tool I was using )CocoaMYSQL for OS X)
is incorrectly displaying data from decimal tables. The actual SQL table has
the correct data, but the dispplay is showing rubbish.
Thanks for your thoughts.
[Back to original message]
|