smetterd
asked on
Cast value as number with 2 decimal places, then be able to average
I am pulling values from a db like this
z0=formatnumber((int(rstem p.Fields.I tem("q1"). Value) + int(rstemp.Fields.Item("q2 ").Value) + int(rstemp.Fields.Item("q3 ").Value) + int(rstemp.Fields.Item("q4 ").Value) + int(rstemp.Fields.Item("q5 ").Value) + int(rstemp.Fields.Item("q6 ").Value) + int(rstemp.Fields.Item("q7 ").Value) + int(rstemp.Fields.Item("q8 ").Value) + int(rstemp.Fields.Item("q9 ").Value)) /9)
z0 then returns a value that I like such as 2.74
z1=formatnumber((int(rstem p2.Fields. Item("q1") .Value) + int(rstemp2.Fields.Item("q 2").Value) + int(rstemp2.Fields.Item("q 3").Value) + int(rstemp2.Fields.Item("q 4").Value) ) /9)
z1 then returns a value that I like such as 3.43
I need to then add them together to get 6.17
Trouble is, of course, that if I do a
response.write z1 + z2
it simply concatenates the text values and returns 2.743.43 - that's not going to work ;-)
If I do a
response.write int(z1) + int(z2)
it returns 5
I am confused!
I need to find out how to make it return 6.17 so I can divide it by 2 and get an average.
z0=formatnumber((int(rstem
z0 then returns a value that I like such as 2.74
z1=formatnumber((int(rstem
z1 then returns a value that I like such as 3.43
I need to then add them together to get 6.17
Trouble is, of course, that if I do a
response.write z1 + z2
it simply concatenates the text values and returns 2.743.43 - that's not going to work ;-)
If I do a
response.write int(z1) + int(z2)
it returns 5
I am confused!
I need to find out how to make it return 6.17 so I can divide it by 2 and get an average.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
both work perfectly. THANKS!!
I deserve full points here, why split ?
glad to help
ASKER
His worked perfectly also, and it's actually less code to write.
The <b>last</b> thing that i want to do is upset someone who helps me... so how can I go about getting you more points?
The <b>last</b> thing that i want to do is upset someone who helps me... so how can I go about getting you more points?
Post a 200 pts Q for me
ASKER
jitganguly,
See https://www.experts-exchange.com/questions/21835492/What's-the-best-procedural-programming-language.html
Thanks!
dsmetter
See https://www.experts-exchange.com/questions/21835492/What's-the-best-procedural-programming-language.html
Thanks!
dsmetter
ASKER
formatnumber(int(z1) + int(z2))
And that returns 5.00
It stripping the value of the two decimal places but I need it to stay!