DSum function results on Single data type (1 Viewer)

adamnorsworthy

Registered User.
Local time
Today, 01:19
Joined
Nov 9, 2005
Messages
13
Hello,

I am using the DSum function on a field that is specified as having:

Field size: Single
Format: General
Decimal Places: 2

I add 5 records to the new table. The contents of the records are:

Record 1: 1
Record 2: 2
Record 3: 3
Record 4: 4
Record 5: 5

The results of the DSum function is 15. Cool. But when I change Record 4's value to 4.1, the result is 15.0999999046326 (instead of 15.1). I get this problem any time using the DSum function on Single field types.

How can I stop this?

Kind regards, Adam.
 

midmented

DP Programmer
Local time
Yesterday, 20:19
Joined
Jun 5, 2008
Messages
94
Did you try Round()? Like dsum(Round(the DSum Statement),1)
 

MStef

Registered User.
Local time
Today, 01:19
Joined
Oct 28, 2004
Messages
2,251
In the table DATA TYPE properties put NUMBER or CURRENCY.
In FIELD SIZE put DOUBLE or CURRENCY.
 

adamnorsworthy

Registered User.
Local time
Today, 01:19
Joined
Nov 9, 2005
Messages
13
Feedback

Hi all,

Thanks for the posts.

Just to let you know - setting the Format property to Fixed didn't work. I wasn't using the Round function and yes, that did work. Regarding the last post, setting if DATA TYPE to currency and the Field size to currency worked, but setting the DATA TYPE to number and Field size to Double didn't work!

I have also found setting the field size to decimal works, but I don't know if they are any draw back to using this rather than using the currency option of the Round function. Any comments?
 

midmented

DP Programmer
Local time
Yesterday, 20:19
Joined
Jun 5, 2008
Messages
94
The only problem with using round instead of defining it in the table is you will always have to use round in code statements. I've always used:

Field Size: Single
Format: Number
Decimal Places: 2

This has always worked for me.
 

Users who are viewing this thread

Top Bottom