[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  Programming
. -> [Folder]  General
. . -> [Subject]  Variables , arrays, float and int

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Variables , arrays, float and int

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Robert Powell   Australia  (349 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (18,769 posts)  [Biography] 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
[Go to top] 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]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]