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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:17:16+00:00 2026-05-25T10:17:16+00:00

I had already searched through different questions on this topic but not get a

  • 0

I had already searched through different questions on this topic but not get a clear idea.
Check this code:

class Test{
    public static void main(String[] s){
        int a=5;
        float b=(float)a/0;
        System.out.print(b);
    }
}

the output is Infinity. But the thing I’m not getting is a is an int and a/0 must throw an exception. So how can it show output 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-25T10:17:17+00:00Added an answer on May 25, 2026 at 10:17 am

    The binary / operator performs division, producing the quotient of its operands. The left-hand operand is the dividend and the right-hand operand is the divisor.

    Integer division rounds toward 0. That is, the quotient produced for operands n and d that are integers after binary numeric promotion (§5.6.2) is an integer value q whose magnitude is as large as possible while satisfying |d·q||n|; moreover, q is positive when |n||d| and n and d have the same sign, but q is negative when |n||d| and n and d have opposite signs. There is one special case that does not satisfy this rule: if the dividend is the negative integer of largest possible magnitude for its type, and the divisor is -1, then integer overflow occurs and the result is equal to the dividend. Despite the overflow, no exception is thrown in this case. On the other hand, if the value of the divisor in an integer division is 0, then an ArithmeticException is thrown.

    The result of a floating-point division is determined by the specification of IEEE arithmetic:

    If either operand is NaN, the result is NaN.
    If the result is not NaN, the sign of the result is positive if both operands have the same sign, negative if the operands have different signs.
    Division of an infinity by an infinity results in NaN.
    Division of an infinity by a finite value results in a signed infinity. The sign is determined by the rule stated above.
    Division of a finite value by an infinity results in a signed zero. The sign is determined by the rule stated above.
    Division of a zero by a zero results in NaN; division of zero by any other finite value results in a signed zero. The sign is determined by the rule stated above.
    Division of a nonzero finite value by a zero results in a signed infinity. The sign is determined by the rule stated above.
    In the remaining cases, where neither an infinity nor NaN is involved, the exact mathematical quotient is computed. A floating-point value set is then chosen:
        If the division expression is FP-strict (§15.4):
            If the type of the division expression is float, then the float value set must be chosen.
            If the type of the division expression is double, then the double value set must be chosen. 
        If the division expression is not FP-strict:
            If the type of the division expression is float, then either the float value set or the float-extended-exponent value set may be chosen, at the whim of the implementation.
            If the type of the division expression is double, then either the double value set or the double-extended-exponent value set may be chosen, at the whim of the implementation. 
    
    Next, a value must be chosen from the chosen value set to represent the quotient. If the magnitude of the quotient is too large to represent, we say the operation overflows; the result is then an infinity of appropriate sign. Otherwise, the quotient is rounded to the nearest value in the chosen value set using IEEE 754 round-to-nearest mode. The Java programming language requires support of gradual underflow as defined by IEEE 754 (§4.2.4). 
    

    Despite the fact that overflow, underflow, division by zero, or loss of information may occur, evaluation of a floating-point division operator / never throws a run-time exception.

    This can be verified at: http://docs.oracle.com/javase/specs/jls/se5.0/html/expressions.html#15.17.2

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

Sidebar

Related Questions

We've had this question already, but I want to narrow it down to already
Hii, there are many others had already post so many question about this..But here
Apologies if this has already been asked and solved but through numerous searches and
This is very specific case. I believe someone had already solved this somewhere, but
Glassfish had already been installed into Netbeans. But I forgot the password and username.
Need some help with this problem in implementing with XSLT, I had already implemented
i already had 2008 express sql server but for some reason it came without
I had already setup the buttons and the layout properly, but I'm having an
I had already installed rails 1.8.7, forgot about it, then installed 1.9.3 through RVM.
(I had already written this question out when I figured out the answer, so

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.