[Valentina] [OFF] Decimal field in mySQL

Ruslan Zasukhin sunshine at public.kherson.ua
Mon Jan 20 16:41:57 CST 2003


on 1/20/03 4:32 PM, Marcus Bointon at marcus at synchromedia.co.uk wrote:

>> But I ask not float type but DECIMAL type,
>> Which do NOT loose digits.
> 
> Oops, sorry.
> MySQL docs say:
> 
>> DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]
>> An unpacked floating-point number. Behaves like a CHAR column: ``unpacked''
>> means the number is stored as a string, using one character for each digit of
>> the value. The decimal point and, for negative numbers, the `-' sign, are not
>> counted in M (but space for these is reserved). If D is 0, values will have
>> no
>> decimal point or fractional part. The maximum range of DECIMAL values is the
>> same as for DOUBLE, but the actual range for a given DECIMAL column may be
>> constrained by the choice of M and D. If UNSIGNED is specified, negative
>> values are disallowed. If D is omitted, the default is 0. If M is omitted,
>> the
>> default is 10. Prior to MySQL Version 3.23, the M argument must include the
>> space needed for the sign and the decimal point.
> 
> So, by default, decimal type fields DO lose precision for the example you
> gave, however, that would be self inflicted as you wouldn't expect a field
> with zero decimal places to store the decimal places, hence you get 7 as
> your answer. If I redefine the fields as decimal(10,1) (instead of
> decimal(10,0)), the calculation works as expected.

Marcus, once again,

If you set f1 and f2 as DECIMAL(10.3)

And f1 =  3.4  
    f2 = 4.8

Then f1 + f2 = 8.2

Yes?

I ask because in sources I cannot find how they do this.
By sources, I see that they do it as 3 + 4 = 7.

I need search more...


-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://listserv.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list