This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Solved

Posted on 2012-09-11

I have a set of numbers to be plot as histogram chart. The Y scale need a short legend for divisor such as M = million, K = thousand .

I need a logic so that the y scale show a meaningful numbers - and also all data will be divided by that divisor.

The set of number changed randomly for each new plot - so algorithm need to work when there are large and small numbers plot together. - no log scale is necessary.

Numbers will not goes below 0 but can be as high as billions.

How should i calculate for divisor, e.g. using average number or max/min etc.

BR,

I need a logic so that the y scale show a meaningful numbers - and also all data will be divided by that divisor.

The set of number changed randomly for each new plot - so algorithm need to work when there are large and small numbers plot together. - no log scale is necessary.

Numbers will not goes below 0 but can be as high as billions.

How should i calculate for divisor, e.g. using average number or max/min etc.

BR,

3 Comments

Assuming a maximum value of x you could do this:

var x=1234567890; //the number to be evaluated

var e=0; //to accumulate the scale

var i=x; //a working variable

//Find the number's scale or order of decimal magnitude

while (i > 1) {

i=i/10;

e++;

}

//Once you have determined the scale for the maximum value in the set, treat all members of the set the same way.

if (e>=9) {

x=x/1E9+"B";

}else if (e>=6) {

x=x/1E6+"M";

}else if (e>=3) {

x=x/1E3+"K";

}

alert(x);

If that really means that ALL plots will be from zero upwards then use the suggestion by Amick.

ps. re Amicks suggestion you could also convert to a string and use the length. eg. "123456789" is 9 chars long = billions

Question has a verified solution.

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

Course of the Month16 days, left to enroll

Join the community of 500,000 technology professionals and ask your questions.