Need help from a python wizard

Clark B. Wierda cbwierda at
Mon Dec 4 23:32:07 UTC 2017

On Mon, Dec 4, 2017 at 5:51 PM, Hal Murray via devel <devel at>

>             days = int(last) / 86400
>             seconds = last - days*86400
> I've kludged some printing.
> days is a float, for example: 17504.9482755
> is int/int supposed to result in an int or a float?
> I expected it to be an int.  This code used to work.  Trying by hand, I get
> an int...
There is a change in the way this is handled by Python between 2 and 3.

You can force integer arithmetic with "//" like 3 // 2 which will result in

It looks like you are trying to get the days and the leftover seconds
(int(last) % 86400).  Also if last is a string value it might be returning
a numeric equivalent of zero.  The actual error is likely not using
"int(last)" in the second case.

However, if I understand the intent, the correct Python solution is "days,
seconds = divmod(int(last), 86400)".

Again, assuming I'm not making an embarrassing omission, the code should
look something like:

        last = ntp.ntpc.lfptofloat(entry.last)
            lstint = int( - last + 0.5)
            stats = "%7d" % lstint
            # direct mode doesn't have a reference time
            MJD_1970 = 40587     # MJD for 1 Jan 1970, Unix epoch
            days, lstint = divmod(int(last), 86400)
            stats = "%5d %5d" % (days + MJD_1970, lstint)

If that is not the issue, I will be glad to take a real look at this in
running code.

Clark B. Wierda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the devel mailing list