Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7635331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:24:15+00:00 2026-05-31T07:24:15+00:00

Why is the difference between two time_t s returned by the difftime( time_t t1,

  • 0

Why is the difference between two time_ts returned by the difftime( time_t t1, time_t t2) method as a double? I don’t see where the precision requirement comes from.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:24:16+00:00Added an answer on May 31, 2026 at 7:24 am

    Because time_t is simply defined in the standard as an arithmetic type capable of representing times.

    That’s about all it says about it. It doesn’t have to be an integer, it doesn’t have to represent seconds. It could only ever be a multiple of ten or it may be a floating point type capable of representing times down to a resolution of 10-43 seconds.

    The quote from C99 7.23.1 Components of time is (slightly paraphrased):

    Types declared are clock_t and time_t, which are arithmetic types capable of representing times. The range and precision of times representable in clock_t and time_t are implementation-defined.

    Hence people who blindly work out the time difference with:

    delta = time_end - time_begin;
    

    may find that their code doesn’t work on all platforms.

    Now I don’t know off the top of my head any platforms where it’s not a simple seconds since the epoch but I’ve been bitten by assumptions like this before, such as assuming A through Z are contiguous whereas, in fact, that is not required and doesn’t work so well on the mainframe products which use EBCDIC. And, yes, they’re still in heavy use despite apparently having been dying since the ’60s 🙂

    The C99 rationale document has this to say:

    The types clock_t and time_t are arithmetic because values of these types must, in accordance with existing practice, on occasion be compared with -1 (a "don’t-know" indication), suitably cast.

    No arithmetic properties of these types are defined by the Standard, however, in order to allow implementations the maximum flexibility in choosing ranges, precisions, and representations most appropriate to their intended application. The representation need not be a count of some basic unit; an implementation might conceivably represent different components of a temporal value as subfields of an integer type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't see any difference between the two functions. Using the following JavaScript code:
I'm looking at namespaces and I don't really see a difference between these and
How to calculate minute difference between two date-times in PHP?
I am feeling surprised by the difference between two seemingly identical scripts. first.ps1: A
I want to get the difference between two sets of ints in c#. Given
I want to calculate the difference between two times, one of which is the
I'm currently working on a class that calculates the difference between two objects. I'm
What is the easiest way to highlight the difference between two strings in PHP?
How can I use DATEDIFF to return the difference between two dates in years,
I'm looking for a way to determine the difference between two dates. A normal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.