Subject Re: [IBO] Float Values and editing
Author Helen Borrie
At 07:21 PM 16/12/2003 +0000, you wrote:
>I am having a problem with what appears to be IB/FB fields and my
>editors (DevExpress). When I set the value of a float field, the
>editor no longer respects the decimal places I told it to have (e.g.
>2) and it gets very long.
>
>For example, if I set a field value to 50.3, I get 53.2999992370605
>showing up in the editor.

Assuming you are using TIBO components...
What did you use to set up the decimal places? Do you have its Currency
property set true?
Are you fetching it into a BCD field object? Are you using AsCurrency to
refer to it?
Do you have an EditMask set for it?

>I understand the problem with float fields their binary
>representation in memory--that doesn't fix this.
>
>Just to check things out I switched over to a dfferent (in-memory)
>dataset and using the same values and field classes and everything
>worked just fine.
>
>I also switched the field to a DECIMAL(15,4) and this fixed it as
>well.

That is the right thing to do if you need to limit the scale of number when
you store it. "Use float for things you measure, fixed decimal for things
you count". Playing around with the scale of floats in the user interface
doesn't cause them to be somehow converted into proper scale when
stored. It just disguises the precision errors.


>But should I have to do that? Why have other dataset's/databases
>worked fine with the same class structure?

Can't answer that, since some components first-guess floats as BCD fields
because they're targeted at desktop DBs that don't have true scaled
numerics. IBO doesn't do that, VCL + IB driver doesn't.

Have you read Geoff Worboys' TechInfo sheet on the topic?

Helen