Mortgages | Artsbook | Credit Cards | Loans | Mortgage Calculator
whole numbers... [Archive] - PCMech Forums

PDA

View Full Version : whole numbers...


artsapimp
10-03-2000, 12:43 PM
I have fixed the cdo problem but now have a really easy one. I am trying to get an average of 5 numbers but want it to round to the nearest whole number. How would I do that in ASP?

IE - 906 instead of 906.45234253243532645.

Thanks

UncaDanno
10-03-2000, 05:36 PM
VBscript, right?
You gotta coerce it to use integers. Depending on the browser, version of IIS, hair color, phase of the moon, etc, forcing one just one of the numbers in the equation may still give you, er, unreliable results.

Start out with cint(avg) = total / five to force the result to an integer.

Or you could go whole-hog and use
cint(avg) = cint(total) / cint(five) ("five" is a variable, by the way)

This will convert all three terms in the equation to integers.

doltish
10-05-2000, 05:00 PM
Well I know that in C you simply have to initialize your variable as int to store an integer...but somehow I doubt VB uses the same method.

artsapimp
10-05-2000, 05:09 PM
I'm sorry for not responding earlier, but UncaDonna was correct. What I was missing was setting the integer first, then taking the Cint(x) of it. That worked. Thanks.