Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

471
Views
Is there a way that double d + 1 == d in java

I'm just curious if there's a way that d + 1 == d. If d is a double. Maybe someone can share some knowledge with me.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Yes, certainly.

class Main {  
  public static void main(String args[]) { 
    System.out.println(1.0e52 + 1); 
  } 
}

prints

1.0E52

This will actually be true for numbers with absolute value at least 253, because the mantissa of a double has 52 bits of precision.

over 4 years ago · Santiago Trujillo Report

0

Absolutely. For very large (or small) doubles (or Double.POSITIVE_INFINITY), floating point precision won't be enough to store the 1 difference and d + 1 == d will be true.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!