Variables , arrays, float and int

Posted by Robert Powell on Sun 25 Jan 2004 09:55 AM — 2 posts, 13,515 views.

Australia #0
I have an array holding a bunch of floats, how would i take out one element, round it up or down to 2 decimal points , stip off the decimal points and move the data into an int variable, sort of like:

float new_array[5]
int some_int

if some_action then
new_array[0]= new_array[0]*some_defign
roundup new_array[0]
strip new_array[0]
some_int = new_array[0]_stripped

Please excuse my cruddy sudo code, oh also the data held in the array should still have the decimal points also could anyone recommend a webiste that has good information / tutorial on c programmin, im currently using the one on about.com and it hardly touches the things im delving into.
Thanks again in advance for all your helps.
Amended on Sun 25 Jan 2004 09:58 AM by Robert Powell
Australia Forum Administrator #1
You want a combination of "for each" to iterate through the array, "round" to round, and CInt to convert to an integer.

See this page for links to download the VBscript documentation:

http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=2

The rounding would look something like this:

a = CInt (Round (a, 2))