Hi
Today I updated the MT5 terminal to latest version, Now I get these two warnings in your class file :
unary minus operator applied to unsigned type, result still unsigned Random.mqh
It happens in two places,
First >> return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); << On the -rot, it's a "uint" and because of that negating it will cause another uint so the warning is correct.
Second >> uint threshold = -bound % bound; << same deal about bound, it's a uint again.
Can you please update the file and fix these two warnings?
Hi
Today I updated the MT5 terminal to latest version, Now I get these two warnings in your class file :
unary minus operator applied to unsigned type, result still unsigned Random.mqh
It happens in two places,
First >> return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); << On the -rot, it's a "uint" and because of that negating it will cause another uint so the warning is correct.
Second >> uint threshold = -bound % bound; << same deal about bound, it's a uint again.
Can you please update the file and fix these two warnings?
It is a bit late, but for the reference, some compiler warn -x still unsigned. So, (0-x) may used to avoid that with no overhead, also we can use the two's complement (~x + 1) as -x = ~x + 1

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Class CRandom:
Random number generation using the 32-bit PCG generator.
Author: amrali