Solved

# Math Functions In Large Numeric Arrays

Posted on 2003-02-28
Medium Priority
190 Views
I have some large arrays (between 1000 and 2000 spots) Anywho I was wondering is there any functions that can find me the sum, product, sort them (least int to largest int), also the natural log of the array. I know there probally is I just haven't searched much. I just hate these for/loops that I keep running to do val = val + array(x) now that isn't what I'm using they look more like

for x = 1 to iDataIndex
array(0) = array(0) + val(0,x)
array(1) = array(1) + val(1,x)
array(2) = array(2) + val(2,x)
array(3) = array(3) + val(3,x)
next x

but any functions can help even better for/loops (especially for the product part) anywho thanks in advance,
MoDrop
0
Question by:MoDrop
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 2

Assisted Solution

Jacamar earned 200 total points
ID: 8048608
to sort an array, this is a very basic method

For inJ = 1 to X-1
for inI = 1 to X-1

if myarray(inI) > myarray(inI+1) then
inTemp = myarray(inI)
myarray(inI) = myarray(inI+1)
myarray (inI+1) = inTemp
end if

Next inI
Next inJ

This will compare two array members that are adjacent to each other.  Which ever one is greater, it will move to the bottom of the array.  So after one pass through(or one inJ), you will have the largest element in your array as the last value.  After 2 passes, you will have the largest 2, and ect, until after X-1 passes you will have them sorted from smallest to largest.

I hope this helps.

Jacamar
0

LVL 2

Accepted Solution

Jacamar earned 200 total points
ID: 8048625
To get the natural log of a value, use

dim NatLog() as single

Redim NatLog(1 to X)

For inI = 1 to X

NatLog(inI) = Log(myarray(inI)

Next inI

Jacamar
0

Expert Comment

ID: 9447428
MoDrop:
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Author Comment

ID: 9464732
Project put on back burner. Thanks for trying.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
###### Suggested Courses
Course of the Month10 days, 7 hours left to enroll