News for hackers. Stuff that matters.
Re:Why Not Comments by gus_massa on Tuesday September 10, 2024 @08:15PM (#41506985)

  x = 86400
If I were forced not to write comments, I'd write that as

  x = 24 * 60 * 60
and let the compiler optimize that.
Re:Why Not Comments by hansvm on Wednesday September 11, 2024 @09:32AM (#41511196)
When writing it inline, I like this approach. I like even better when these things have names. Something like `std.time.s_per_day` or `time_utils.s_per_day`. Then in the one place they're defined, use a pattern like the above to make them easy to reason about.
Re:Why Not Comments by DanHulton on Wednesday September 11, 2024 @12:00PM (#41512621)
One step further:

    DAY_IN_SECONDS = 24 * 60 * 60
Re:Why Not Comments by throwaway14356 on Wednesday September 11, 2024 @11:48PM (#41517409)
SECONDS_PER_MINUTE = 60;

MINUTES_PER_HOUR = 60;

HOURS_PER_DAY = 24;

DAYS_PER_SECOND = SECONDS_PER_MINUTE * MINUTES_PER_HOUR * HOURS_PER_DAY

Re:Why Not Comments by CRConrad on Thursday September 12, 2024 @02:48AM (#41518204)
> DAYS_PER_SECOND = SECONDS_PER_MINUTE * MINUTES_PER_HOUR * HOURS_PER_DAY

Naah.

DAYS_PER_SECOND = 1 / (SECONDS_PER_MINUTE * MINUTES_PER_HOUR * HOURS_PER_DAY) ;