On Tue, Jun 30, 2015 at 4:32 AM, Stefan Beller <sbeller@xxxxxxxxxx> wrote: > for calculating the minutes we would only need to take % 3600 (which > you do), but > then we still need to divide by 60 to convert seconds to minutes? Whoops, yes we do. It should be: tz = tz / 3600 * 100 + tz % 3600 / 60; tz = -tz; However... > What happens if we have a negative input not matching a full hour, say -5400 ? > (would equate to 0130 in git) Hmm, I assumed that in C, integer division would always truncate to zero, but turns out that is only so in C99. In C89, it is implementation defined whether it rounds towards zero or towards negative infinity. So, if the compiler rounds towards negative infinity, then the above will give the incorrect result. The best solution is probably to ensure that all the integers are positive: tz2 = labs(tz) / 3600 * 100 + labs(tz) % 3600 / 60; if (tz > 0) tz2 = -tz2; Thanks for bringing this up. Regards, Paul -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html