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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:29:42+00:00 2026-06-12T05:29:42+00:00

I can store a number as a Long and Double in HBase. Both of

  • 0

I can store a number as a Long and Double in HBase. Both of them takes 8 bytes in Java.

Advantage of Using Double is that it gives a more wider range for storing Whole Numbers.

However, i think range of Long is also enough for my use.

Does anyone has any idea about the serialization and de-serialization performance of Long vs Dobule? I am interested in comparison between them.

Thanks.

  • 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-12T05:29:43+00:00Added an answer on June 12, 2026 at 5:29 am

    If you are storing integers, use Long. Your statement that “Advantage of Using Double is that it gives a more wider range for storing Whole Numbers” is incorrect. Both are 64 bits long, but double has to use some bits for the exponent, leaving fewer bits to represent the magnitude. You can store larger numbers in a double but you will lose precision.

    In other words, for numbers larger than some upper bound you can no longer store adjacent “whole numbers”… given an integer value above this threshold, the “next” possible double will be more than 1 greater than the previous number.

    For example

    public class Test1  
    {
    
        public static void main(String[] args) throws Exception 
        {
            long   long1 = Long.MAX_VALUE - 100L;
            double dbl1  = long1;
            long   long2 = long1+1;
            double dbl2  = dbl1+1;
            double dbl3  = dbl2+Math.ulp(dbl2);
    
            System.out.printf("%d %d\n%f %f %f", long1, long2, dbl1, dbl2, dbl3);
        }
    
    }
    

    This outputs:

    9223372036854775707 9223372036854775708
    9223372036854776000.000000 9223372036854776000.000000 9223372036854778000.000000
    

    Note that

    1. The double representation of Long.MAX_VALUE-100 does NOT equal the original value
    2. Adding 1 to the double representation of Long.MAX_VALUE-100 has no effect
    3. At this magnitude, the difference between one double and the next possible double value is 2000.

    Another way of saying this is that long has just under 19 digits precision, while double has only 16 digits precision. Double can store numbers larger than 16 digits, but at the cost of truncation/rounding in the low-order digits.

    If you need more than 19 digits precision you must resort to BigInteger, with the expected decrease in performance.

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

Sidebar

Related Questions

It's known that in .NET size of both long and double is 8 bytes.
I am attempting to store a variable length number that can have leading zeros
How can I store a version number in a static library (file.a) and later
How can I store and retrieve the number 2**10000 in a binary file in
I'm using Hibernate to store a data model, which has a number of simple
Problem: I can't store the number '600851475143'. I realize this number is bigger than
I need to store a large number of Long values in a SortedSet implementation
I'm trying to store and retrieve numbers in android so later I can do
I can store Session State in InProc or State Server or Sql Server. If
how we can store the e mail id into a database? i mean 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.