Problem: Decimals disappear (Solved) 
Author Message
 Problem: Decimals disappear (Solved)

I wrote (edited):

Quote:



> [snip]
> > > Database: Interbase.
> > > Table1 contains a field of type NUMERIC(6,2).

> > > delphi app:

> > > However, the decimals have disappeared in the column; also in DBEdit
> > > fields.

> > The only TField components supporting decimalsI am aware of are
> > TFloatfield and TCurrencyfield. Use the latter, it "stores" data as a
> > fixed point real with 4 decimal places. Otherwise, you will have to
> > resort to rolling your own.

> > HTH

> Thanks, I'll get to work with that.
> But are currency fields really so unusual that people have to use
> workarounds to make DBGrids and stuff work with them? Strange...

Or I could try Reading The Friendly Manual (well, maybe not 'friendly').

Cause of the problem was: I declared the fields as NUMERIC(6,2)
Interbase stores them as INTEGER.
Remedy: declare fields as NUMERIC(10,2)
Interbase stores these as Double precision.
Delphi now sees the decimals.
Problem solved.

Arjan Bokx
--
(replace underscore with dash for email reply)



Sun, 25 Mar 2001 03:00:00 GMT  
 Problem: Decimals disappear (Solved)

Thought you might be interested in this.  It is actually a 'bug' in Interbase.



Hello Stacy,
Does following mirror what you are encountering?

CREATE TABLE PAY_CHEQUE (
                           > GROSSPAY NUMERIC(15,2) NOT NULL,
                           > TAX NUMERIC(15,2) NOT NULL,
                           > CPP NUMERIC(15,2) NOT NULL,
                           > EI NUMERIC(15,2) NOT NULL,
                           > NETPAY COMPUTED BY(GROSSPAY - TAX - CPP
-
EI))
                           > INSERT INTO PAY_CHEQUE
                           > (GROSSPAY, TAX, CPP, EI)
                           > VALUES
                           > (200.930000, 19.104999, 5.094999, 6.104999)

                           >
                           > INTERBASE returns the following for
NETPAY:

                           >
                           > 200.930000      GROSSPAY
                           > -19.104999      -TAX
                           > - 5.094999      -CPP
                           > - 6.104999      -EI
                           > ----------
                           > 170.625003      NETPAY
                           >
                           > However this is what is expected for
NETPAY:

                           > 200.93          GROSSPAY
                           > -19.10          -TAX
                           > - 5.09          -CPP
                           > - 6.10          -EI
                           > ------
                           > 170.64          NETPAY
                           >
                           > The problem appears to be that:
                           > ANY VARIABLE DEFINED AS A NUMERIC(15,2)
                           > APPEARS TO BE STORED AS NUMERIC(15,15)

 Unfortunately,  the currency data type is not included in InterBase 5.0

                           Take a look at:
                           Functions in FreeUDFLib:
                           Math Functions:
                                DollarVal(var Value: Double): PChar;
                                     Format the Value in a string
representation with two places of
                           precision.

                           This and other UDFs are avaivalble to
download at no charge from our website:
                           http://www.interbase.com/download/
                           Click on Free UDF Library.

                           Hope this is of help,
                           Kathleen



Sun, 25 Mar 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem: Decimals disappear

2. Problems with decimals and anonther small problem

3. Binary Coded Decimal (BCD) to Ascii/Decimal

4. annoying problem with dbgrid (disappearing row)

5. Want to solve your BDE problems?

6. A problem solved ?

7. Problem-solving in Math/Science

8. I have an impossible problem.( can anyone think they can solve this )

9. Problem not solved yet

10. Solved! Database Update Problem

11. No one can ever solve this problem...

12. I have solved my problems with fast CPU and Clipper/Pascal

 

 
Powered by phpBB® Forum Software