|
Variables , arrays, float and int
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Robert Powell
Australia (349 posts) bio
|
| Date |
Sun 25 Jan 2004 09:55 AM (UTC) [ quote
] Amended on Sun 25 Jan 2004 09:58 AM (UTC) by Robert Powell
|
| Message |
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. |
EldhaMUD Game Developments
The_Fury: Lead Developer, Head Coder
http://fury.eldhamud2.org
| top |
|
| Posted by |
Nick Gammon
Australia (18,769 posts) bio
Forum Administrator |
| Date |
Reply #1 on Sun 25 Jan 2004 07:53 PM (UTC) [ quote
] |
| Message |
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)) |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
1,238 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )