Why do I get a warning?

 

Hi,

to calc the NY-Session I use:

11    #define ClsSess           57600 // = 16*3600 = 16h
      ...
55    datetime secLeftInNY(){
         ...
58       datetime tNY = getNYTime(TimeGMT());
59       if ( TimeDayOfWeek(tL)>0 && TimeDayOfWeek(tL)<6 && TimeHour(tL) >=8 && TimeHour(tL) < 16 ) 
60           return( (datetime)86400*MathFloor(tNY/86400) + (datetime)ClsSess - tNY );
61       return((datetime)-1);
62    }

The numbers are the line nubmers.

The warning is:

possible loss of data due to type conversion    TimeShifts.mqh  60      3

I get the same warning even before I added all the (datetime)-casting.

Why do I get this warning on the expression being returned?

Gooly


I got it this is ok - no warning:

return( (datetime)(86400*MathFloor(tNY/86400) + ClsSess - tNY) );
 
     return( (datetime)86400*MathFloor(tNY/86400) + (datetime)ClsSess - tNY );
tNY/86400 is a datetime/int try
return( 86400*((ulong)tNY/86400) + ClsSess - tNY );
Reason: