B4R Question time_t to long (multiplication gives wrong value)

KMatle

Expert
Licensed User
Longtime User
Probably a beginner's mistake. The conversation seems to work but multiplying with 1000 gives a wrong value.

Time2: 1620597600 -> OK
Time3: 1620597600 -> OK
Time4: 1394929408-> * 1000 -> wrong

Any ideas?


B4X:
         long int sec = (long int)mktime(&timeinfo); // make time_t
        
       //const time_t sec = mktime(&timeinfo); // make time_t
         printf("Time2: %ld\n",sec);
      
      long int ep=(long int)sec;
       printf("Time3: %ld\n",ep);
            
      ep=ep*1000;
       printf("Time4: %ld\n",ep);
 

JordiCP

Expert
Licensed User
Longtime User
Long type in B4R is 4 bytes

Multiplying 1394929408 (0x5324EF00) by 1000 results in 1.394.929.408.000 (0x144 C845 9800), which is more than 4 bytes

 
Upvote 0
Top