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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:59:31+00:00 2026-06-05T13:59:31+00:00

I have an array of double values where the last one will be in

  • 0

I have an array of double values where the last one will be in fact a long representing time in milliseconds. Therefore this long needs to be converted to a double to fit into the array. Later at the time of retrieval of this long value it needs to be converted back to a long type. It is critical that the long value after retrieval from the array of doubles is exactly the same value (down to a one millisecond) I had before putting it into the array. There will be no operations whatsoever performed on the long value while in the array. So the questions are:

Should I simply cast the long value to double and upon retrieval cast it back to long? Will this preserve the exact value of my long?

Or should I use Double.longBitsToDouble(time) method to put the long into the array and retrieve it with Double.doubleToLongBits(time).

Or maybe I should put the long value into the array using Double.longBitsToDouble(time) and retrieve the encoded long by simply casting it to long type?

Thank you in advance for your help.

  • 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-05T13:59:32+00:00Added an answer on June 5, 2026 at 1:59 pm

    I mean, what you should do is to not use an array to represent values meaning different things…

    But from what it sounds like, you have no choice but to use Double.longBitsToDouble, since a double cannot give you full precision on all long values. Just casting a long to double will lose precision.

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

Sidebar

Related Questions

In my program I have one array with 25 double values 0.04 When I
I have a long integer (ie 10001000110...) and an array with double values (ie
I have an array of double pointers, but every time I try do print
I have a double array as follows: $values[$ids][$dates] So for each $id I have
I have problem in getting wrong values in array of double. Instead of getting
I have a sorted array of double values in C++. Is there an STL
I have an array of double values vals, I need to randomly index into
I have an array of double values containing negative and positive numbers (eg. -2.5
I have a double converted to a unsigned char array. For example for value
I have an double array alist[1][1]=-1 alist2=[] for x in xrange(10): alist2.append(alist[x]) alist2[1][1]=15 print

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.