Q1. I don't understand why the percentage is 0.0 % if correct on should be 0.875 %?
Integer arithmetic is cast to a double type. Make one operand a double type or multiply by 1.0. See Typecasting.
Before operations (except for the assignment ones) are performed, the data are converted into the maximum priority type. Before assignment operations are performed, the data are cast into the target type.
Examples:
int i=1/2; // no types casting, the result is 0 Print("i = 1/2 ",i); int k=1/2.0; // the expression is cast to the double type, Print("k = 1/2 ",k); // then is to the target type of int, the result is 0 double d=1.0/2.0; // no types casting, the result is 0.5 Print("d = 1/2.0; ",d); double e=1/2.0; // the expression is cast to the double type, Print("e = 1/2.0; ",e);// that is the same as the target type, the result is 0.5 double x=1/2; // the expression of the int type is cast to the double target type, Print("x = 1/2; ",x); // the result is 0.0
Q2 and Q3 depend on how your simple string array is structured and the contents. Is the array one dimension or is it a two dimensional array? Does the array have currency symbols (as in your original post) or something else? Please give a small example.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I have simple array with strings (about 800 entries).
But now I want to determinate frequency of each different string element. Idea is to take first element of array and then run over all array and count how many times it shows up there.
So my calculation is that the loop should repeat 800x800=640 000 times
My output :
.....
GBP;JPY;USD;CHF;EUR;EUR;CHF;USD;JPY;GBP vs GBP;JPY;USD;CHF;EUR;EUR;CHF;USD;JPY;GBP
GBP;JPY;USD;CHF;EUR;EUR;CHF;USD;JPY;GBP repeats 7 times. With percentage of 0.0%
Q1. I don't understand why the percentage is 0.0 % if correct on should be 0.875 %?
Q2. Why loop repeats just one time and with first array's element, why is that ? My code looks good.
Q3. Is this a good practice to do such easy job to get frequency of single string?
Thanks a lot :)