Re: [lazarus] TDBgrid float: bug?

2007-05-08 Thread Jesus Reyes

--- Andrea Mauri <[EMAIL PROTECTED]> escribió:

> Dear all,
> I have some problems with TDBgrid and float values.
> Firebird database.
> I have a table with two fields.
> One field is a (FIELD_FLOAT) FLOAT and the other DOUBLE PRECISION 
> (FIELD_DOUBLE).
> I tried some inserts and I show the table using DBGrid.
> If I exec this:
> insert into TABLE1 (FIELD_FLOAT, FIELD_DOUBLE) values (0.15, 9.11)
> 
> In the DBgrid I see:
> FLOAT field: 0.15005960464
> DOUBLE field: 9.109
> 
> In delphi I see the same as in lazarus for the float field but for
> the 
> double I see correctly 9.11
> 
> I think that there are some problems with significant digits.
> I tried to explore the code of TDBgrid ut I was not able to
> understand 
> it. I am a newbie.
> Any help, suggestion?
> a.
> 

Dbgrid only handles strings, conversion from numeric fields is done
through TField.AsString, so is not surprising that you didn't find
anything in dbgrid.

I think this needs to be checked in fcl-db, but there is an easy
solution, add custom columns to your dbgrid and for the column
holding your float fields set an appropiated DisplayFormat, for
example #,###.00 or something, the format mask string should is
described in formafloat function:
http://freepascal.org/docs-html/rtl/sysutils/formatfloat.html

Jesus Reyes A. 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


RE: [lazarus] TDBgrid float: bug?

2007-05-08 Thread Pieter Valentijn
Use numeric(12,2) or what ever to create a numeric field with set
decimal.


Met vriendelijke groet, 
Pieter Valentijn
 
Delphidreams
http://www.delphidreams.nl
 


-Oorspronkelijk bericht-
Van: Andrea Mauri [mailto:[EMAIL PROTECTED] 
Verzonden: dinsdag 8 mei 2007 17:33
Aan: lazarus@miraclec.com
Onderwerp: [lazarus] TDBgrid float: bug?


Dear all,
I have some problems with TDBgrid and float values.
Firebird database.
I have a table with two fields.
One field is a (FIELD_FLOAT) FLOAT and the other DOUBLE PRECISION 
(FIELD_DOUBLE).
I tried some inserts and I show the table using DBGrid.
If I exec this:
insert into TABLE1 (FIELD_FLOAT, FIELD_DOUBLE) values (0.15, 9.11)

In the DBgrid I see:
FLOAT field: 0.15005960464
DOUBLE field: 9.109

In delphi I see the same as in lazarus for the float field but for the 
double I see correctly 9.11

I think that there are some problems with significant digits.
I tried to explore the code of TDBgrid ut I was not able to understand 
it. I am a newbie.
Any help, suggestion?
a.


_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TDBgrid float: bug?

2007-05-09 Thread Andrea Mauri

Using numeric field type the results is the same as for double

insert into TABLE1 (FIELD_FLOAT, FIELD_DOUBLE, FIELD_NUMERIC) values (0.15, 
9.11)

In the DBgrid I see:

FLOAT field: 0.15005960464
DOUBLE field: 9.109
NUMERIC(12,2) field: 9.109

It is a formatting problem.
I will try with displayformat
a.




Pieter Valentijn wrote:

Use numeric(12,2) or what ever to create a numeric field with set
decimal.


Met vriendelijke groet, 
Pieter Valentijn
 
Delphidreams

http://www.delphidreams.nl
 



-Oorspronkelijk bericht-
Van: Andrea Mauri [mailto:[EMAIL PROTECTED] 
Verzonden: dinsdag 8 mei 2007 17:33

Aan: lazarus@miraclec.com
Onderwerp: [lazarus] TDBgrid float: bug?


Dear all,
I have some problems with TDBgrid and float values.
Firebird database.
I have a table with two fields.
One field is a (FIELD_FLOAT) FLOAT and the other DOUBLE PRECISION 
(FIELD_DOUBLE).

I tried some inserts and I show the table using DBGrid.
If I exec this:
insert into TABLE1 (FIELD_FLOAT, FIELD_DOUBLE) values (0.15, 9.11)

In the DBgrid I see:
FLOAT field: 0.15005960464
DOUBLE field: 9.109

In delphi I see the same as in lazarus for the float field but for the 
double I see correctly 9.11


I think that there are some problems with significant digits.
I tried to explore the code of TDBgrid ut I was not able to understand 
it. I am a newbie.

Any help, suggestion?
a.


_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

  


--
Andrea Mauri
PhD student - Chemical Sciences
Milano Chemometrics and QSAR Research Group
Department of Environmental Sciences
University of Milano-Bicocca 
P.zza della Scienza, 1

20126 Milano - Italy

Tel: ++39 02 64482801
mailto:[EMAIL PROTECTED]
http://www.disat.unimib.it/chm/ 


_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TDBgrid float: bug?

2007-05-09 Thread Andrea Mauri

I am checking the displayformat property.
Checking it I found in DBGrids unit:

procedure TColumn.Assign(Source: TPersistent);
begin
 if Source is TColumn then begin
   //DebugLn('Assigning TColumn[',dbgs(Index),'] a TColumn')
   Collection.BeginUpdate;
   try
 inherited Assign(Source);
 FieldName := TColumn(Source).FieldName;
*  DisplayFormat := TColumn(Source).FieldName;*
 ValueChecked := TColumn(Source).ValueChecked;
 ValueUnchecked := TColumn(Source).ValueUnchecked;
   finally
 Collection.EndUpdate;
   end;
 end else
   inherited Assign(Source);
end;

Bug?
a.

Jesus Reyes wrote:

--- Andrea Mauri <[EMAIL PROTECTED]> escribió:

  

Dear all,
I have some problems with TDBgrid and float values.
Firebird database.
I have a table with two fields.
One field is a (FIELD_FLOAT) FLOAT and the other DOUBLE PRECISION 
(FIELD_DOUBLE).

I tried some inserts and I show the table using DBGrid.
If I exec this:
insert into TABLE1 (FIELD_FLOAT, FIELD_DOUBLE) values (0.15, 9.11)

In the DBgrid I see:
FLOAT field: 0.15005960464
DOUBLE field: 9.109

In delphi I see the same as in lazarus for the float field but for
the 
double I see correctly 9.11


I think that there are some problems with significant digits.
I tried to explore the code of TDBgrid ut I was not able to
understand 
it. I am a newbie.

Any help, suggestion?
a.




Dbgrid only handles strings, conversion from numeric fields is done
through TField.AsString, so is not surprising that you didn't find
anything in dbgrid.

I think this needs to be checked in fcl-db, but there is an easy
solution, add custom columns to your dbgrid and for the column
holding your float fields set an appropiated DisplayFormat, for
example #,###.00 or something, the format mask string should is
described in formafloat function:
http://freepascal.org/docs-html/rtl/sysutils/formatfloat.html

Jesus Reyes A. 



__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 


_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

  


--
Andrea Mauri
PhD student - Chemical Sciences
Milano Chemometrics and QSAR Research Group
Department of Environmental Sciences
University of Milano-Bicocca 
P.zza della Scienza, 1

20126 Milano - Italy

Tel: ++39 02 64482801
mailto:[EMAIL PROTECTED]
http://www.disat.unimib.it/chm/ 



Re: [lazarus] TDBgrid float: bug?

2007-05-09 Thread Andrea Mauri

How can I access the DisplayFormat property?

I can see it only in the object inspector and not by code:

DBGrid1.Columns[0] .displayformat

Doesn't exist.
a.


Jesus Reyes wrote:

--- Andrea Mauri <[EMAIL PROTECTED]> escribió:

  

Dear all,
I have some problems with TDBgrid and float values.
Firebird database.
I have a table with two fields.
One field is a (FIELD_FLOAT) FLOAT and the other DOUBLE PRECISION 
(FIELD_DOUBLE).

I tried some inserts and I show the table using DBGrid.
If I exec this:
insert into TABLE1 (FIELD_FLOAT, FIELD_DOUBLE) values (0.15, 9.11)

In the DBgrid I see:
FLOAT field: 0.15005960464
DOUBLE field: 9.109

In delphi I see the same as in lazarus for the float field but for
the 
double I see correctly 9.11


I think that there are some problems with significant digits.
I tried to explore the code of TDBgrid ut I was not able to
understand 
it. I am a newbie.

Any help, suggestion?
a.




Dbgrid only handles strings, conversion from numeric fields is done
through TField.AsString, so is not surprising that you didn't find
anything in dbgrid.

I think this needs to be checked in fcl-db, but there is an easy
solution, add custom columns to your dbgrid and for the column
holding your float fields set an appropiated DisplayFormat, for
example #,###.00 or something, the format mask string should is
described in formafloat function:
http://freepascal.org/docs-html/rtl/sysutils/formatfloat.html

Jesus Reyes A. 



__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 


_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

  


--
Andrea Mauri
PhD student - Chemical Sciences
Milano Chemometrics and QSAR Research Group
Department of Environmental Sciences
University of Milano-Bicocca 
P.zza della Scienza, 1

20126 Milano - Italy

Tel: ++39 02 64482801
mailto:[EMAIL PROTECTED]
http://www.disat.unimib.it/chm/ 



Re: [lazarus] TDBgrid float: bug?

2007-05-09 Thread Jesus Reyes

--- Andrea Mauri <[EMAIL PROTECTED]> escribió:

> I am checking the displayformat property.
> Checking it I found in DBGrids unit:
> 
> procedure TColumn.Assign(Source: TPersistent);
> begin
>   if Source is TColumn then begin
> //DebugLn('Assigning TColumn[',dbgs(Index),'] a TColumn')
> Collection.BeginUpdate;
> try
>   inherited Assign(Source);
>   FieldName := TColumn(Source).FieldName;
> *  DisplayFormat := TColumn(Source).FieldName;*
>   ValueChecked := TColumn(Source).ValueChecked;
>   ValueUnchecked := TColumn(Source).ValueUnchecked;
> finally
>   Collection.EndUpdate;
> end;
>   end else
> inherited Assign(Source);
> end;
> 
> Bug?

Yes a typo, it's fixed in r5

Thanks.

Jesus Reyes A.


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TDBgrid float: bug?

2007-05-09 Thread Jesus Reyes

--- Andrea Mauri <[EMAIL PROTECTED]> escribió:

> How can I access the DisplayFormat property?
> 
> I can see it only in the object inspector and not by code:
> 
> DBGrid1.Columns[0] .displayformat
> 
> Doesn't exist.
> a.

try TColumn(DBGrid1.Columns[0]).DisplayFormat

Jesus Reyes A.

__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives