Wrong result of a sum

G

Guest

I have the following procedure:

Me![DTime] = (24 - (Me![HoursRun] + Me![StandBy]))
when I enter to Me![HoursRun]=23.6; Me![StandBy]=0.3
The result (Me![DTime] ) comes .099999999 and not 0.1
Me![DTime], Me![HoursRun], Me![StandBy])) are fields from a table as double

Could you help me what's wrong?

José Perdigão
 
B

Bas Cost Budde

Nothing wrong, really, this is just how real numbers work on a computer.

If you do int(yourexpression * 100 + .5) /100, you will get at true cents.

Jose said:
I have the following procedure:

Me![DTime] = (24 - (Me![HoursRun] + Me![StandBy]))
when I enter to Me![HoursRun]=23.6; Me![StandBy]=0.3
The result (Me![DTime] ) comes .099999999 and not 0.1
Me![DTime], Me![HoursRun], Me![StandBy])) are fields from a table as double

Could you help me what's wrong?

José Perdigão
 
S

Steve Schapel

José,

I would recommend changing the data type of these fields to Currency
rather than Number/Double.
 
G

Guest

I can not understand,
if we have an expression 24-(23.6-0.3)=should be 0.1 and not .099999999
where they are 3 fields number as double
x=23.6
Y=03
Z= result should be .1, becuase x+y+z should be equal 24



Steve Schapel said:
José,

I would recommend changing the data type of these fields to Currency
rather than Number/Double.

--
Steve Schapel, Microsoft Access MVP


Jose said:
I have the following procedure:

Me![DTime] = (24 - (Me![HoursRun] + Me![StandBy]))
when I enter to Me![HoursRun]=23.6; Me![StandBy]=0.3
The result (Me![DTime] ) comes .099999999 and not 0.1
Me![DTime], Me![HoursRun], Me![StandBy])) are fields from a table as double

Could you help me what's wrong?

José Perdigão
 
B

Bas Cost Budde

The number is stored as floating point. In the conversion a slight error
is conceivable. Floating point numbers work this way, floating point is
*claimed* to be imprecise now and then. Please live with it and code
appropriately.
 
G

Guest

I need help, could you help me how can I do?
The expressions in the queries are de same, the precision is not correct.
 
G

Guest

It means, we must not use number/double? If we use double always we hve this
problem?
Thanks

Steve Schapel said:
José,

I would recommend changing the data type of these fields to Currency
rather than Number/Double.

--
Steve Schapel, Microsoft Access MVP


Jose said:
I have the following procedure:

Me![DTime] = (24 - (Me![HoursRun] + Me![StandBy]))
when I enter to Me![HoursRun]=23.6; Me![StandBy]=0.3
The result (Me![DTime] ) comes .099999999 and not 0.1
Me![DTime], Me![HoursRun], Me![StandBy])) are fields from a table as double

Could you help me what's wrong?

José Perdigão
 
S

Steve Schapel

José,

Yes, this is correct. You should use Double Field Size if you need
numbers with more than 7 decimal places, up to 15 decimal places, or if
you need to use the very large numerical values that it allows. But it
is Floating Point data, and there will always be slight imprecision. If
you do not require the use of decimals, then use an Integer or Long
Integer Field Size setting. If you need decimals, but 4 or less decimal
places, use a Currency data type.
 
S

Steve Schapel

José,

As Bas Cost Budde has pointed out, this is expected behaviour for a
Double Field Size. There are simply certain numerical values and
certain calculations which computers are not capable of handling. It's
a fact of life. One option is to use a rounding function to get your
data closer to what you want. I do not recommend this approach, unless
no other option is available. In your database, do you ever need more
than 4 decimal places in the numbers you are working with? Or use a
number greater than 922,337,203,685,477? If not, as I mentioned before,
the correct Data Type is Currency. With a Currency Data Type,
24-(23.6+0.3)=0.1 precisely. The name of this data type is a bit
confusing... it is not just meant for money. But you will need at times
to set the Format property to General Number so it does not display a
currency symbol.
 
G

Guest

Thanks Steve,
I tried to use currency size, in the table I formatted to general number, I
open the table and the symbol of money didn't appear. It works fine.
I open the query where I have calculations and the result come currency
(money), unless I use format function.
So, I resolved one problem, I got new problem.
I’m disappointed.
 
G

Guest

Thanks Steve,
If I use currency size, in the table i format to general number, I open the
table and the symbol of money didn't appear.
I open the query where I have calculations and the result comes currency
(money) unless I use format function.
So, I resolved one problem, I got new problem.
this is frustad



the result of calculations comes in money, unless i use format function. So,
is not good option. I get one solution and I get new problem.
 
S

Steve Schapel

José,

Normally you don't see the data in a table or query, so normally it
doesn't matter what it looks like. When you are displaying this data on
a form or report, you will sometimes need to use the Format property of
the textbox (as distinct from a Format() function), so the money symbol
is not shown. I agree that it can be irritating until you get it set up
how you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top