Any questions from a PROFI to a SUPER PROFI - 1. - page 24

 
    if (h>0) s=1; if (h<0) s=-1;
   Comment(" цена впадины ZZ = ",LouZZ);
   R1 = LouZZ+s*(5*pips);   R2 = LouZZ+s*(18*pips);   R3 = LouZZ+s*(39*pips);
   R4 = LouZZ+s*(68*pips);  R5 = LouZZ+s*(105*pips);  R6 = LouZZ+s*(150*pips);   
   R7 = LouZZ+s*(203*pips); R8 = LouZZ+s*(264*pips);  R9 = LouZZ+s*(333*pips);    
   
   S1 = LouZZ+s*(1*pips);   S2 = LouZZ+s*(10*pips);   S3 = LouZZ+s*(27*pips);
   S4 = LouZZ+s*(52*pips);  S5 = LouZZ+s*(85*pips);   S6 = LouZZ+s*(126*pips);   
   S7 = LouZZ+s*(175*pips); S8 = LouZZ+s*(232*pips);  S9 = LouZZ+s*(297*pips);    
 
sergeev:

thank you I'm so stupid))))+- gives a minus to go)))))))))

live and learn, live and die a fool))))) works, thanks Alexei for reminding me of the school curriculum...

   if(h<l){s=1; Comment(" цена впадины ZZ = ",LouZZ);}else{s=-1;Comment(" цена вершины ZZ = ",LouZZ);}

   R1 = LouZZ+s*(5*pips);   R2 = LouZZ+s*(18*pips);   R3 = LouZZ+s*(39*pips);
   R4 = LouZZ+s*(68*pips);  R5 = LouZZ+s*(105*pips);  R6 = LouZZ+s*(150*pips);   
   R7 = LouZZ+s*(203*pips); R8 = LouZZ+s*(264*pips);  R9 = LouZZ+s*(333*pips);    
   
   S1 = LouZZ+s*(1*pips);   S2 = LouZZ+s*(10*pips);   S3 = LouZZ+s*(27*pips);
   S4 = LouZZ+s*(52*pips);  S5 = LouZZ+s*(85*pips);   S6 = LouZZ+s*(126*pips);   
   S7 = LouZZ+s*(175*pips); S8 = LouZZ+s*(232*pips);  S9 = LouZZ+s*(297*pips);  
 

advise how to encode a matrix in which fields can take one of the values of the set {-1,0,1,2,3,4} (five states in total), I would like to have some function that can encode a matrix of the form:

| -1,0,1,2,3,4, -1,0,1,2,3,4 |
| -1,0,1,2,3,4, -1,0,1,2,3,4 |
| -1,0,1,2,3,4, -1,0,1,2,3,4 |
| -1,0,1,2,3,4, -1,0,1,2,3,4 |
| -1,0,1,2,3,4, -1,0,1,2,3,4 |
| -1,0,1,2,3,4, -1,0,1,2,3,4 |

save to several integers: int arr[6] = {xxxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx}, with the least amount of computational effort

cps

 
Show me an example of your matrices.
 
sergeev:
Show me an example of your matrices.


| 4,4,1,2,1,1, 1,1,1,1,1,1 |
| 4,4,1,2,1,1, 1,1,1,1,1,1 |
| 4,4,4,2,1,1, 1,1,1,1,1,1 |
| 4,3,3,3,3,3, -1,-1,-1,-1,-1,-1 |
| 3,3,3,3,3,3, -1,-1,-1,-1,-1,-1|
| 3,3,3,3,3,3, -1,-1,-1,-1,-1,-1|

next:

| 4,4,1,2,2,2, 1,1,1,1,1,1 |
| 4,4,1,2,2,2, 1,1,1,1,1,-1 |
| 3,4,4,2,2,2, 1,1,1,1,1,-1 |
| 4,3,3,3,3,3, 1,1,1,-1,-1,-1 |
| 3,3,3,3,3,3, -1,-1,-1,-1,-1,-1|
| 3,3,3,3,3,3, -1,-1,-1,-1,-1,-1|

I want to compactly store data - one line, one integer

 
IgorM:

Advise how to encode a matrix in which fields can take one of the values of the set {-1,0,1,2,3,4} (five states in total),


Shift it into the positive region by 2 units to remove 0 and -1 (followed by restoration after reading) and you can easily form an integer.
 
granit77:
Shift into the positive range by 2 units to remove 0 and -1 (followed by restoration after reading) and an integer can easily be formed.


Well, let the set be {0,1,2,3,4,5} - it does not matter, it is important from this group of digits to get an integer, if at this stage I have a 12x6 matrix, you can get something in the form:

| 4,4,1,2,1,1, 1,1,1,1,1,1 | = 2147483647 - 441211111111/2

seems to fit into int, but I don't know, what if you want matrix 100x6 ;)

SZY: from the Help: Internal representation of int is a long integer of size 4 bytes. Integer constants can take values from -2147483648 to 2147483647. If the constant exceeds the specified range, the result is undefined.

 
Well, you still have string variables to spare, although they will be slower. But 0 and -1 must be removed.
 
granit77:
Well, you still have string variables to spare, although they will be slower. But 0 and -1 must be removed.
Yes! So far there are only string variables - the algorithm itself is still on "paper", I am preparing data for uploading to a file, but then we will need to analyze the data, and that's where speed is needed, while I think how to unload to int instead of stringi
 

Usually DBMS store group data as a string. The processing speed with large volumes is a pain in the ass. I haven't followed what happened with Clarion, look it up - C compatibility was top-notch there.

Reason: