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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:19:21+00:00 2026-05-28T17:19:21+00:00

If I run following line of code, I get DIVIDE BY ZERO error 1.

  • 0

If I run following line of code, I get DIVIDE BY ZERO error

1. System.out.println(5/0);

which is the expected behavior.

Now I run the below line of code

2. System.out.println(5/0F);

here there is no DIVIDE BY ZERO error, rather it shows INFINITY

In the first line I am dividing two integers and in the second two real numbers.

Why does dividing by zero for integers gives DIVIDE BY ZERO error while in the case of real numbers it gives INFINITY

I am sure it is not specific to any programming language.

  • 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-28T17:19:22+00:00Added an answer on May 28, 2026 at 5:19 pm

    (EDIT: The question has been changed a bit – it specifically referred to Java at one point.)

    The integer types in Java don’t have representations of infinity, “not a number” values etc – whereas IEEE-754 floating point types such as float and double do. It’s as simple as that, really. It’s not really a “real” vs “integer” difference – for example, BigDecimal represents real numbers too, but it doesn’t have a representation of infinity either.

    EDIT: Just to be clear, this is language/platform specific, in that you could create your own language/platform which worked differently. However, the underlying CPUs typically work the same way – so you’ll find that many, many languages behave this way.

    EDIT: In terms of motivation, bear in mind that for the infinity case in particular, there are ways of getting to infinity without dividing by zero – such as dividing by a very, very small floating point number. In the case of integers, there’s obviously nothing between zero and one.

    Also bear in mind that the cases in which integers (or decimal floating point types) are used typically don’t need to concept of infinity, or “not a number” results – whereas in scientific applications (where float/double are more typically useful), “infinity” (or at least, “a number which is too large to sensibly represent”) is still a potentially valid result.

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

Sidebar

Related Questions

I have a line of code that gets the following error when run through
if i try to run following code in sql server 2005 i get error
When I run this code I get the following error error: invalid label html_attributions
I'm trying to run the following line: Directions.loadFromWaypoints((Waypoint[])waypoints.toArray(), opts); But I'm getting: 23:41:44.595 [ERROR]
If you run the following code you get the output: The answer is: <br>
when my event fires the following code get's run: WebBrowser browser = new WebBrowser();
I read a guide . It says that run the following line and forget
I've run across the following line in a VB6 application. mobjParentWrkBk.ExcelWorkBook.Application.Selection.Insert Shift:=xlToRight Unfortunately Google
I run the following Gert's extract command to the data dump file which format
when ever i write the following line of code any where in any app

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.