Errors, bugs, questions - page 1128

 

In "normal" comparisons, it is given to the unsigned type:

void OnStart()
{
  ulong i=0;
  while(true)
  {
    if(i<ULONG_MAX) {i++;}  //тут в условии так и остаётся тип ulong, преобразования к long не происходит
    else {break;}
  }
}
 
Fleder:

Then how do you explain it:

long t=0;
  bool comp=(ULONG_MAX-1>t);
  Print("comp = ",comp);   //comp = true
Bitwise comparison - there is no contradiction. And then - comparing ulong and long is only incorrect if long < 0
 
void OnStart()
{
  long n=0;
  uint g=UINT_MAX;
//for(int i=0;i<UINT_MAX;i++) {n++;}  //здесь получаем бесконечный цикл и предупреждение expression is always true
  for(int i=0;i<g;i++) {n++;}         //здесь получаем предупреждение sign mismatch и цикл в 4294967295 итераций
  Print("n = ",n);                    //n = 4294967295            
}

In the tested expression of the first loop, a variable of int type is compared to an integer constant of uint type:

there is no implicit type conversion, a bitwise comparison is performed. The expression is always true.

In the second loop's expression being checked, a variable of the int type is compared to a variable of the uint type:

an implicit conversion of the variable i to the type uint is performed. And after the overflow of the i variable: uint(-1)= 4294967295

the expression will be false.


 

The end of an era(UNIX?)is delayed by 8 hours:

Whole types

Type

Size in bytes

Minimum value

Maximum value

Analog in C++

datetime

8

0 (1970.01.01 0:00:00)

32 535 244 799 (3000.12.31 23:59:59)

__time64_t

void OnStart()
{
  Print((datetime)32535244799);   //3001.01.01 07:59:59
}
 

Developers,

Give him a formal description of the MQL grammar, let him look for boogers :-)))

 

Simple thing:

double min,max;

i=Bars-1-period1;
while(max-min==0)
{
min=Low[i];
max=High[i];
i++;
}

On TF: D1 and M4 the debugger rejects the line min=Low[i]; the terminal "hangs". On other TF this problem does not exist. Replacing by min=iLow(); does not do anything. Please, advise, where is the "hole": in the history, in the new MT4 editor or in my head?

 
admoon:

Simple stuff:

   double min,max;

   i=Bars-1-period1;
   while(max-min==0)
     {
      min=Low[i];
      max=High[i];
      i++;
     }

On TF: D1 and M4 the debugger rejects the line min=Low[i];, the terminal "hangs". On other TF this problem does not exist. Replacement on min=iLow(); does not give me anything. Please, advise where is the "hole": in history, in new MT4 editor or in my head?

Pleaseuse the "SRC" button when creating a forum post to insert the code


This will make it easier to read your messages.

 
Fleder:

The end of an era(UNIX?)is delayed by 8 hours:

There must be a mistake in the help
Print( ulong(::StringToTime( "3000.12.31 23:59:59" ))); //32'535'215'999

Or we don't know something, I think someone even hand-counted it here https://www.mql5.com/en/forum/16036

 
A100:
Apparently there is an error in help max=32'535'215'999

It's just that the limit for datetime type is not defined correctly:

void OnStart()
{
  Print((datetime)32535244799);   //3001.01.01 07:59:59
  Print((datetime)32535244800);   //wrong datetime
}
 
Fleder:

The limit for datetime type is simply not defined correctly:

32'535'244'799 != 32'535'215'999 - which is correct?
Reason: