C allows for various scalar numbers (integers, floating point) to represent time. It needs to be a "... real types capable of representing times" C11 §7.27.1 3,
The range and precision of times representable in clock_t and time_t
are
implementation-defined. C11dr §7.27.1 4
The difference between 2 time_t
values, as a double
affords a vary wide range and precision.
OP, "Since 'number of seconds' doesn't require floating-point numbers, why does this function return a double?
[Edit] Linux/posix might not use fractions of seconds, but other systems have done so. The C standard that defines difftime()
choose double
and that accommodates an integer accumulation of seconds as well as other OS implementations.