Libraries: Class CRandom

 

Class CRandom:

Random number generation using the 32-bit PCG generator.

Class CRandom

Author: amrali 

Class CRandom
Class CRandom
  • www.mql5.com
GbpChf Advisor for trading Gbp/Chf. Algorithm for bar opening prices. Timeframe H1. ArrowDrawingIndiEu This indi will draw OBJ_ARROW_BUY/OBJ_ARROW_SELL when find signals on Arrow Indi Buffers. Accelerator Oscillator (AC) The...
 

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?


 
Alireza Khodakarami #:

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