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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:01:36+00:00 2026-06-05T18:01:36+00:00

With 32 bit floats I think there is something like 2^31 – 1 representable

  • 0

With 32 bit floats I think there is something like 2^31 – 1 representable floats. In java you can take an existing float and find the “next float” using the Math library. But lets say you don’t have a starting float, is there a way to compute the nth float? I don’t care what language, if there is a language with a library function I’ll take it.

Of course I could simply put all the floats in an array and index into that, but that is space inefficient.

Here is some further clarification. I could start at Float.MIN and increment N times using nextFloat, but this seems inefficient because I need to perform this operation many times.

  • 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-05T18:01:39+00:00Added an answer on June 5, 2026 at 6:01 pm

    Depends on how you want them ordered. Keep in mind that not all floats are ordered at all; for instance, a pair of distinct NaNs are unordered (i.e, they are not equal, but neither one is greater than the other).

    If you don’t mind ending up with those, you can just reinterpret an integer as a float. The way you’d do this varies from language to language; here’s a C implementation:

    float int_to_float(uint32_t in) {
        union {
            float f;
            uint32_t i;
        } u;
    
        u.i = in;
        return u.f;
    }
    

    This has the convenient property of giving you mostly ordered results — passing in zero gets you 0.0, one gets you 1.4e-45, 2 gets you 2.8e-45, and so on. The results will start getting crazy once you get into NaN/Inf values, and will eventually start decreasing once you hit 0x80000000 (-0.0), but that should be good enough for now.

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

Sidebar

Related Questions

I assume that on a 32-bit device like the iPhone, assigning a short float
Excerpt from a book: A float value consists of a 24-bit signed mantissa and
How to convert the following hex string to float (single precision 32-bit) in Python?
I'm a bit puzzled about the conditional operator. Consider the following two lines: Float
Bit of an odd question but is there a way of seeing what objects
I'm trying to position two lines of text next to a single word like
My site looks like this: I've coloured the central info bit red, so you
I've been trying to find info on performance of using float vs double on
I'm trying to make a parser for a simple functional language, a bit like
If anyone can get this guy's small bit of code working on their machine,

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.