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 1113783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:54:28+00:00 2026-05-17T02:54:28+00:00

I have a 64-bit timestamp unpacked from a file with binary data, where the

  • 0

I have a 64-bit timestamp unpacked from a file with binary data, where the top 32 bits are the number of seconds and the bottom 32 bits are the fraction of the second. I’m stuck with how to actually convert the bottom 32 bits into a fraction without looping through it bit-by-bit.

Any suggestions?

For reference, the number 4ca1f350 9481ef80 translates to 1285682000.580107659

Edit:
For context: the data comes from a packet capture device and the documentation I’ve seen says that it the fractional part has roughly nano-second precision (specifically it outputs 29 of the 32 bits, giving ~2ns).

  • 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-17T02:54:29+00:00Added an answer on May 17, 2026 at 2:54 am

    To represent the sum of integral and fractional part with enough precision (32 + 29 = 61 bits), you need a Decimal (28 decimal digits by default, which is enough for 93 bits),

    >>> from decimal import Decimal
    >>> Decimal(0x9481ef80) / Decimal(2**32) + Decimal(0x4ca1f350)
    Decimal('1285682000.580107659101486206')
    

    or Fraction (exact),

    >>> from fractions import Fraction
    >>> Fraction(0x9481ef80, 2**32) + Fraction(0x4ca1f350)
    Fraction(43140329262089183, 33554432)
    >>> float(_)
    1285682000.5801077
    

    Note that a float uses “IEEE double format” so it can only hold 53 bits of precision:

    >>> a = 0x9481ef80 / 2**32 + 0x4ca1f350
    >>> b = 0x9481ef90 / 2**32 + 0x4ca1f350
    >>> a == b
    

    It is fine if you store the fractional part as its own variable, but if that’s the case, why not just keep it as-is?

    >>> 0x9481ef80 / 2**32
    0.5801076591014862
    >>> 0x9481ef90 / 2**32
    0.5801076628267765
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a bit of confusion here. I added a few objects from a class
I have a bit of code that fits theoretical prediction to experimental data, and
I have the following query: SELECT * from foo where timestamp = (select max(timestamp)
I bit of a puzzle to solve in CF here. You have a timestamp
I have a Unix timestamp that comes from a database that is (unfortunately) in
I have some xml that looks like this: <?xml version=1.0?> <data> <items> <item><timestamp>2011-07-11T09:01:42Z</timestamp><title><![CDATA[ some
I have an input file that I want to sort based on timestamp which
I'm trying to rescale a timestamp (fractional part of seconds only) from nanoseconds (units
So i have this file of 10,000+ lines of messages from a game server,
Hi I have created an array from core-data using: NSArray* invoiceItem =[fetchedResultsController fetchedObjects]; which

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.