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

  • SEARCH
  • Home
  • 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 8652117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:14:02+00:00 2026-06-12T14:14:02+00:00

Currently I am using boost::rational<std::uint64> to keep track in my application. Basically I have

  • 0

Currently I am using boost::rational<std::uint64> to keep track in my application.

Basically I have a clock that runs over a very long period of time and will be tick by different components of different time resolutions, e.g. 1/50s, 1/30s, 1001/30000s etc… I want to maintain perfect precision, i.e. no floating point. boost::rational works well for this purpose, however I think it would be better design to use std::chrono::duration for this.

My problem though is, how can I use std::chrono::duration here? Since it uses a compile time period I don’t quite see how I can use it in my scenario where I need to maintain precision?

  • 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-06-12T14:14:04+00:00Added an answer on June 12, 2026 at 2:14 pm

    You’re allowed to set the period to 1 and use a floating point type for Rep.

    I suspect that you can do the same thing with boost::rational, but you’ll have to look quite closely at std::chrono, which I haven’t done. Look at treat_as_floating_point and duration_values. Also try to figure out what the standard means by “An arithmetic type or a class emulating an arithmetic type”.

    One might reasonably argue that if boost::rational doesn’t emulate an arithmetic type, then it’s not doing its job. But it doesn’t necessarily follow that it really does everything std::chrono::duration expects.

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

Sidebar

Related Questions

I am currently writing an application(using boost) that will have one producer grabbing frames
I'm currently using Boost's multi-index to help keep track of how many times a
I'm currently writing an application, which communicates with another application using boost::interprocess . However
To narrow it down: I'm currently using Boost.Unordered . I see two possible solutions:
Currently using Xcode 4.2 and I have two view controllers (1 and 2). I
I currently using android NDK to write some native code in C. I have
We're currently using the following for creating US dollar values in our web application:
I'm currently using the boost threadpool with the number of threads equal to the
I'm using Boost.Test for Unit testing and am currently running various mock servers in
How would I do case insensitive string comparison using boost locale? Currently I do

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.