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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:29:13+00:00 2026-05-25T11:29:13+00:00

double d=1/0.0; System.out.println(d); It prints Infinity , but if we will write double d=1/0;

  • 0
double d=1/0.0;
    System.out.println(d);

It prints Infinity , but if we will write double d=1/0; and print it we’ll get this exception: Exception
in thread "main" java.lang.ArithmeticException: / by zero
at D.main(D.java:3)
Why does Java know in one case that diving by zero is infinity but for the int 0 it is not defined?
In both cases d is double and in both cases the result is infinity.

  • 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-25T11:29:14+00:00Added an answer on May 25, 2026 at 11:29 am

    Floating point data types have a special value reserved to represent infinity, integer values do not.

    In your code 1/0 is an integer division that, of course, fails. However, 1/0.0 is a floating point division and so results in Infinity.

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

Sidebar

Related Questions

Here's an example: Double d = (1/3); System.out.println(d); This returns 0, not 0.33333... as
For example: double a = 2000; System.out.println(a); Prints out 2000.0, whereas I would like
I have written code below.but it will print this exception and i really don't
After running the following lines : double d=Float.parseFloat(9.99); System.out.println(+d); I got this : 9.989999771118164
Here's what I do: double x = 7.0; System.out.printf(%.2f, x); Eclipse gives me this
I was just wondering if there was a way to use System.out.println(); or other
Integer i1= new Integer(9); Integer i2= new Integer(9); if(i1==i2){ System.out.println(true); }else{ System.out.println(false); } int
I want to print out the result of calcWork() in printReport() but I keep
System.out.println(300 + ((160 - 300) / (240 - 20)) * (27 - 20)); //Should
System.out.println(Please enter the required word :); Scanner scan = new Scanner(System.in); String word =

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.