Features of the mql5 language, subtleties and tricks - page 65

 

how to reduce the size of the file with binary data to the new data size, without removing the file itself, or only through calling external dll can be implemented?

 
Konstantin:

How to reduce file with binary data to the new data size, without removing the file itself, or only by calling external dll can be implemented?

I need an analogue of SetEndOfFile function.

It was asked about it about 6 years ago

 
Combinator:

We need an analogue of the SetEndOfFile function.

It was asked about it about 6 years ago

That's what I'm writing about )) because it's not kasher to do it via external dll or file deletion

 
Combinator:

We need an analogue of the SetEndOfFile function.

It was asked about it about 6 years ago.

bool SetEndOfFile( const string FileName, const uint Size, const int Commong_Flag = 0 )
{
  uchar Buffer[];
  
  return((FileLoad(FileName, Buffer, Commong_Flag) > Size) && ArrayResize(Buffer, Size) && FileSave(FileName, Buffer, Commong_Flag)));
}
 
fxsaber:

the file will change its size only upwards, if the data array is reduced, the file will remain the same size

 
Konstantin:

file will change its size only upwards, if the data array is reduced, the file will remain with the same size

Decreases.

 
fxsaber:
That's a hell of an overhead.
 
Combinator:
That's a hell of an overkill.

Absolutely!

 
Once again about double

Forum on trading, automated trading systems and trading strategies testing

Bugs, bugs, questions

fxsaber, 2018.01.15 11:53

Because the input fmod is double. Double can't store a huge number of integers. For example, your case:

Print(DoubleToString((double)131472503841474907, 0)); // 131472503841474912

Do this.

long fmod( const long Value, const long Value2 )
{
  return(Value % Value2);
}


Using the float example, you can quickly understand the peculiarity of double

#define  PRINT(A) Print(#A + " = " + (string)(A))

void OnStart()
{
  for (int i = 0; i < INT_MAX; i++)
    if ((int)(float)i != i)
    {
      PRINT(i);
      PRINT((float)i);
      PRINT((double)i);
      
      break;
    }
}


Result

i = 16777217
(float)i = 16777216.0
(double)i = 16777217.0


SZY double doesn't lose the information of the whole int-range, not so with long.

 
Konstantin:

This is what I'm writing about )) because it's not kasher to do through external dll or delete a file

saw it, wanted to but forgot

Ошибки, баги, вопросы
Ошибки, баги, вопросы
  • 2011.08.01
  • www.mql5.com
Общее обсуждение: Ошибки, баги, вопросы