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

Doubles with large exponents overflow to Infinity incorrectly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 9
    • 8, 9
    • core-libs
    • b33
    • x86_64
    • windows_7
    • Verified

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "1.8.0_05"
        Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
        Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

        A DESCRIPTION OF THE PROBLEM :
        When a small number followed by a large exponent, >= 326 Double.parseDouble outputs Infinity whereas new BigDecimal(text).doubleValue() doesn't.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        String text325 = "0.00000000000000001e325";
        System.out.println(Double.parseDouble(text325));
        System.out.println(new BigDecimal(text325).doubleValue());
        String text326 = "0.000000000000000001e326";
        System.out.println(Double.parseDouble(text326));
        System.out.println(new BigDecimal(text326).doubleValue());


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        1.0E308
        1.0E308
        1.0E308
        1.0E308
        ACTUAL -
        1.0E308
        1.0E308
        Infinity
        1.0E308

        REPRODUCIBILITY :
        This bug can be reproduced always.

        CUSTOMER SUBMITTED WORKAROUND :
        Use BigDecimal

        Don't use such obtuse format for numbers.

        Attachments

          Issue Links

            Activity

              People

                bpb Brian Burkhalter
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: