Multiply Double and Integer Returns Integer

I am attempting to calculate the average of four percentage values, Each value has an associated integer, representing the number of times an action happened, with the percentage indicating success/failure.

To get the average mathematically I use the following (p = % value, i = integer):

((p1i1)+(p2i2)+(p3i3)+(p4i4))/(i1+i2+i3+i4)

The p and i values are retrieved from text fields in a NotesDocument using the GetFirstItem method. My problem occurs when multiplying the p and i values using the LS below:

For x = 1 To 4 'Cycle through report weeks

	incr = x-1

	week%=wk%-incr

	id% = 13-x

	

	

	If week% <=0 Then

		week% = 52-incr

		yr% = yr%-1

	End If

	

	For y = 1 To 4 'Cycle through data source weeks

		src% = id%-(y+3)

		Set cnt = doc.GetFirstItem("dctCount_"+Cstr(src%))

		Set sat = doc.GetFirstItem("dctSat_"+Cstr(src%))

		dcttotal(y) = cnt.Values(0)*sat.Values(0)

		dctcount(y) = cnt.Values(0)

	Next

	Call doc.ReplaceItemValue("dctCount_"+Cstr(id%), dctcount(1)+dctcount(2)+dctcount(3)+dctcount(4))

	Call doc.ReplaceItemValue("dctSat_"+Cstr(id%), (dcttotal(1)+dcttotal(2)+dcttotal(3)+dcttotal(4))/(dctcount(1)+dctcount(2)+dctcount(3)+dctcount(4)))

Next

Example, p1 = 0.9857, i1 = 67. Expected return value is 66.0419 of type double. Actual return value is 66

The debugger shows that sat.Values(0) is of type double and cnt.Values(0) is of type integer. My understanding was that multiplying a double by an integer would return a double.

Any suggestions? All are welcome as I’m obviously far from expert.

Thanks, Dave

Subject: Simplify

I can’t reproduce the problem. When I simplify your case, I get a result that is exactly what you expect (66.0419). If that helps…

Subject: I’d like to…

Sadly, my values are variable retrieved from NotesItems and not simple data types as in your example - in my debugger cnt.Values(0) is a variant of type double and sat.values(0)is also a variant of type double. When these are multiplied together they produce dcttotal(1) of type double with a value of 66 only. The other thing I notice is that for both NotesItems the type property is 768, indicating numbers, and the data type is indicated to be LONG - could this be the problem?

I’ve also tried passing the NotesItem values to variables of simple data type double with the same result.