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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:30:05+00:00 2026-06-15T21:30:05+00:00

If two double values(a and b) which both are not negative both are not

  • 0

If two double values(a and b) which

  1. both are not negative
  2. both are not an NaN nor any (POSITIVE|NEGATIVE)_INFINITY,
  3. a >= b

Is it always true that

  1. Double.doubleToLongBits(a) >= Double.doubleToLongBits(b)

?

Is there any possible false per IEEE 754 stuff?

I’m intending to store a rate value for two positive (non-zero) integers as a long value not as a double value.

@Entity
public class ExchangeRate {

    @PrePersist
    protected void prePersist() {
        targetAmountPerSourceAmount = Double.doubleToLongBits(
            (double) targetAmount / (double) sourceAmount);
    }

    @Basic
    private long targetAmountPerSourceAmount;

    @Min(1)
    @Max(Short.MAX_VALUE)
    private short targetAmount;

    @Min(1)
    @Max(Short.MAX_VALUE)
    private short sourceAmount;
}
  • 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-15T21:30:07+00:00Added an answer on June 15, 2026 at 9:30 pm

    Well, zeros are going to cause you a problem, since +0.0 == -0.0 but they have different representations.

        double a = -0.0;
        double b = +0.0;
        System.out.println("a == b? " + (a == b)); // true
        long aLong = Double.doubleToLongBits(a);
        long bLong = Double.doubleToLongBits(b);
        System.out.println("a' >= b'? " + (aLong >= bLong)); // false
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a two-dimension ArrayList that contains double values: ArrayList<ArrayList<Double>> data = new ArrayList<ArrayList<Double>>();
I have a mathematical formula in my program that takes in two values, both
I have two lists of double values which have the same length. Is it
I need a double table from which I get two values from a key
I'm using two different TapGestureRecognizer to handle both single and double tap on screen.
I have two arrays values and keys both of the same length. I want
I have a function which takes two parameters: string[], double[] How do I return
Lets say I'm interacting with a system that has two incrementing counters which depend
A simple comparison of two double values in Java creates some problems. Let's consider
I have an ArrayList<Double> , the values of which are converted into slices of

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.