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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:24:43+00:00 2026-05-14T16:24:43+00:00

Can you help me clarify the usages of the float primitive in Java? My

  • 0

Can you help me clarify the usages of the float primitive in Java?

My understanding is that converting a float value to double and vice-versa can be problematic. I read (rather long time ago and not sure that it’s actual true anymore with new JVMs) that float’s performance is much worse than double’s. And of course floats have less precision than double.

I also remember that when I worked with AWT and Swing I had some problems with using float or double (like using Point2D.Float or Point2D.Double).

So, I see only 2 advantages of float over double:

  1. It needs only 4 bytes while double needs 8 bytes

  2. The Java Memory Model (JMM) guarantees that assignment operation is atomic with float variables while it’s not atomic with double’s.

Are there any other cases where float is better then double? Do you use float in your applications?

  • 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-14T16:24:43+00:00Added an answer on May 14, 2026 at 4:24 pm

    The reason for including the float type is to some extent historic: it represents a standard IEEE floating point representation from the days when shaving 4 bytes off the size of a floating point number in return for extremely poor precision was a tradeoff worth making.

    Nowadays, uses for float are pretty limited. But, for example, having the data type can make it easier to write code that needs interoperability with older systems that do use float.

    As far as performance is concerned, I think the float and double are essentially identical except for the performance of divisions. Generally, whichever you use, the processor converts to its internal format, does the calculation, then converts back again, and the actual calculation effectively takes a fixed time. In the case of divisions, on Intel processors at least, as I recall the time taken to do a division is generally one clock cycle per 2 bits of precision, so that whether you use float or double does make a difference.

    Unless you really really have a strong reason for using it, in new code, I would generally avoid ‘float’.

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

Sidebar

Related Questions

Maybe you can help me... I am writing a program in Windows Mobile that
Are there any algorithms that can help with hierarchical clustering? Google's map-reduce has only
I would like information on algorithms that can help identify commonality and differences between
Is there anything which can help with msmq monitoring? I'd like to get some
Wondering if anyone can help me with this annoying but trivial (in terms of
I have heard using PDB files can help diagnose where a crash occurred. My
Hopefully some Custom Control Designers/Builders can help I'm attempting to build my first custom
I was wondering if anyone can help me get started with creating a room
I am wondering if someone can help me figure out the best approach to
I would be extremely appreciative if anybody can help me. I am learning C++

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.