public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: apbianco@redhat.com To: gcc-gnats@gcc.gnu.org Subject: libgcj/4583: problems BigDecimal(double) ctor. Date: Tue, 16 Oct 2001 13:26:00 -0000 [thread overview] Message-ID: <20011016201938.25319.qmail@sourceware.cygnus.com> (raw) >Number: 4583 >Category: libgcj >Synopsis: problems BigDecimal(double) ctor. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Oct 16 13:26:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Alex Petit-Bianco >Release: unknown-1.0 >Organization: >Environment: linux/x86, current trunk. >Description: I'm running into the following situation with BigDecimal. Consider this code: private static final BigDecimal minDouble = new java.math.BigDecimal(Double.MIN_VALUE); It ends up throwing a java.lang.NumberFormatException. It seems to be that Long.parseLong doesn't handle what it is given as an argument (`50E-324', and `scale' in BigDecimal would be modified accordingly) as Long.parseLong won't handle anything but digits, and the exception is thrown from there: private static long parseLong(String str, int index, int len, boolean isNeg, int radix) throws NumberFormatException { ... if ((digval = Character.digit(str.charAt(index), radix)) < 0) throw new NumberFormatException(); Long.parseLong() complies with the spec, but BigDecimal uses Double.toString to convert the input number. If the input can't be represented in a string without using the scientific notation, Long.parseLong() won't receive something it can deal with. 4.0e-4 instead of Double.MIN_VALUE will trigger the same error; but 4.0e-3 won't. The attached test case can be use and could be added to our testsuite. >How-To-Repeat: Build BIG.java. >Fix: Not yet. One can work around the problem by hand crafting a string representation of Double.MIN_VALUE or Double.MAX_VALUE that doesn't use a scientific notation. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/x-java; name="BIG.java" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="BIG.java" aW1wb3J0IGphdmEubWF0aC5CaWdEZWNpbWFsOwppbXBvcnQgamF2YS5tYXRoLkJpZ0ludGVnZXI7 CgpjbGFzcyBCSUcgewogIHByaXZhdGUgc3RhdGljIGZpbmFsIEJpZ0ludGVnZXIgbWluRG91Ymxl ID0KICAgIG5ldyBqYXZhLm1hdGguQmlnRGVjaW1hbChEb3VibGUuTUlOX1ZBTFVFKS50b0JpZ0lu dGVnZXIoKTsKICBwcml2YXRlIHN0YXRpYyBmaW5hbCBCaWdJbnRlZ2VyIG1heERvdWJsZSA9CiAg ICBuZXcgamF2YS5tYXRoLkJpZ0RlY2ltYWwoRG91YmxlLk1BWF9WQUxVRSkudG9CaWdJbnRlZ2Vy KCk7CiAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZykKICB7CiAgfQp9Cg==
next reply other threads:[~2001-10-16 13:26 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-10-16 13:26 apbianco [this message] 2001-11-20 18:09 tromey 2001-11-20 18:16 tromey
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20011016201938.25319.qmail@sourceware.cygnus.com \ --to=apbianco@redhat.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).