Solved

# Sort SMALL numbers in bins

Posted on 2006-11-12

I have alot extremely small numbers that I need to sort and add into bins to keep count, which is going to be used for a histogram. I have a loop that is chosing 20 numbers from an array of 25 numbers (it can select the same number multiple times). The array stores doubles ranging from 0.0 to 1.0. The numbers i'm multiplying look somehting like this:

2.580645e-01

3.225806e-01

9.677419e-02

6.451613e-02

2.580645e-01

Multiplying these numbers are giving me results that look like this:

9.536743e-03

5.293956e-09

5.651273e-22

I think the smallest I saw was Xe-24. I'm going to end up with a ton of these, about 5^20 worth of numbers!

As I am multiplying, how can I sort these results into MAXBIN number of bins to be used for a histogram? I'm using 1000 for MAXBIN, for example here is part of my code (Not exactly the best ):

#define STEPS 20

#define MAXN 5

#define MAXBIN 1000

int counter[STEPS];

double pathTotal;

int c;

for (c0 = 0; c0 < MAXN; c0++) {

counter[0] = c0;

for (c1 = 0; c1 < MAXN; c1++) {

counter[1] = c1;

...

for (c19 = 0; c19 < MAXN; c19++) {

counter[19] = c19;

pathTotal = 1;

for (c = 0; c < STEPS; c++) {

pathTotal = pathTotal * arr[counter[c]][counter[c+1]];

/* INSERT CODE TO ADD TO BIN FOR COUNT */

}