ASP Not dividing correct

ASP Not dividing correct

am 01.12.2004 19:40:38 von Support

Here is the values I have:

Number = 5
Funds = 5.60

Average = 1.2

ASP is incorrect. When I do it with my calculator I get
1.12 as the Average not 1.2. Why am I getting this:

Here is my code
-----code ----------
Number = cint(Children) + cint(Adults)
Average = (clng(Funds) / cint(Number)
response.write "Number = " & number
response.write "Funds = " & Funds

response.write "Average = " & Average

Re: ASP Not dividing correct

am 01.12.2004 19:53:08 von unknown

You're CLng'ing 5.6, which will round it up to 6. 6/5=1.2. Instead of
CLng, use CSng.

Ray at work


"John Smith" wrote in message
news:063901c4d7d5$409eeea0$a401280a@phx.gbl...
> Here is the values I have:
>
> Number = 5
> Funds = 5.60
>
> Average = 1.2
>
> ASP is incorrect. When I do it with my calculator I get
> 1.12 as the Average not 1.2. Why am I getting this:
>
> Here is my code
> -----code ----------
> Number = cint(Children) + cint(Adults)
> Average = (clng(Funds) / cint(Number)
> response.write "Number = " & number
> response.write "Funds = " & Funds
>
> response.write "Average = " & Average
>
>
>

Re: ASP Not dividing correct

am 01.12.2004 19:53:49 von reb01501

John Smith wrote:
> Here is the values I have:
>
> Number = 5
> Funds = 5.60
>
> Average = 1.2
>
> ASP is incorrect. When I do it with my calculator I get
> 1.12 as the Average not 1.2. Why am I getting this:
>
> Here is my code
> -----code ----------
> Number = cint(Children) + cint(Adults)
> Average = (clng(Funds) / cint(Number)
> response.write "Number = " & number
> response.write "Funds = " & Funds
>
> response.write "Average = " & Average


Do this to see your problem:

response.write "clng(Funds) = " & clng(Funds)

Then try this:
Average = (csng(Funds) / csng(Number)
response.write "Average = " & Average




--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Re: ASP Not dividing correct

am 01.12.2004 21:38:58 von Support

Worked great. Thank you!!!


>-----Original Message-----
>You're CLng'ing 5.6, which will round it up to 6.
6/5=1.2. Instead of
>CLng, use CSng.
>
>Ray at work
>
>
>"John Smith" wrote
in message
>news:063901c4d7d5$409eeea0$a401280a@phx.gbl...
>> Here is the values I have:
>>
>> Number = 5
>> Funds = 5.60
>>
>> Average = 1.2
>>
>> ASP is incorrect. When I do it with my calculator I get
>> 1.12 as the Average not 1.2. Why am I getting this:
>>
>> Here is my code
>> -----code ----------
>> Number = cint(Children) + cint(Adults)
>> Average = (clng(Funds) / cint(Number)
>> response.write "Number = " & number
>> response.write "Funds = " & Funds
>>
>> response.write "Average = " & Average
>>
>>
>>
>
>
>.
>