[fpc-pascal] Double and LongWord
    Jonas Maebe 
    jonas.maebe at elis.ugent.be
       
    Fri Nov 22 12:02:16 CET 2013
    
    
  
On 22 Nov 2013, at 10:56, Carsten Bager wrote:
> This Function works on Intel platforms but when compiled to Arm  
> (Linux) the right side is
> calculated as a LongWord.
>
> Const
>  cSecondsPerDay=86400.0;
>  cTimeDate2UnixFiledateStart=25569.0;
>   
> cUnixFileDateDateTimeStart=cSecondsPerDay*cTimeDate2UnixFiledateStart;
>
> Function UnPackUnixTime2DateTime(UnixTime:LongWord):TDateTime;
> Begin
>  UnPackUnixTime2DateTime:=(UnixTime+cUnixFileDateDateTimeStart)/ 
> cSecondsPerDay;
> End;
On all platforms the compiler will evaluate this expression using  
single precision, because all used floating point constants fit in  
single precision. The x87 is however limited in the sense that it can  
only perform calculations using extended precision, so you won't  
notice it there. You should probably also typecast  
cUnixFileDateDateTimeStart to double precision because otherwise you  
may encounter overflows if UnixTime is too large.
Jonas
    
    
More information about the fpc-pascal
mailing list