![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
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...
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.
| 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
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 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.
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.