Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8225646

Float and Double Division by Zero throws no Exception

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 12.0.1
    • Fix Version/s: None
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Description

      A DESCRIPTION OF THE PROBLEM :
      The major Problem is, that "double" and "float" knows infinity and act in every time. So the handling does not recognize the concept in Math of a division by zero. This is not expected for developer and an expected Exception isn't thrown. -Infinity and Infinity means counts over an casting limitation of possible numbers. But a division by zero is not infinite and means an infinity stepcount of calculations.


              //hidden for the compiler
              System.out.println(Float.valueOf("100") / Float.valueOf("0") * 1);

              //Several IDE's yells , but returns infinity
              System.out.println((float) 100 / (float) 0 * 10);
              System.out.println((double) 100 / (double) 0 * 10);

              //drop an java.lang.ArithmeticException: / by zero
              System.out.println((int) 100 / (int) 0 * 10);


        Attachments

          Activity

            People

            Assignee:
            psonal Pallavi Sonal (Inactive)
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: