JDK-4069162 : BigDecimal - problem with signed strings e.g. "+0"
  • Type: Enhancement
  • Component: other-libs
  • Sub-Component: other
  • Affected Version: 1.1.3
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 1997-08-01
  • Updated: 1999-07-15
  • Resolved: 1999-07-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.3.0 betaFixed
Related Reports
Relates :  
Description

Name: rlT66838			Date: 08/01/97


import java.math.*;

public class bd
{
   public static void main(String args[])
   {
      String inString = (args.length>0) ? args[0] : "+0.00";

         BigDecimal bigDec = new BigDecimal(inString);

         System.out.println("inString = " + inString);
         System.out.println("bigDec   = " + bigDec);
   }

}


company - sun , email - ###@###.###
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic kestrel-beta FIXED IN: kestrel-beta INTEGRATED IN: kestrel-beta
14-06-2004

EVALUATION The spec currently does not permit a leading + sign in the String representation of a BigDecimal or a BigInteger. This was done for consistency with Integer(String), which also prohibits a leading + sign. However Float(String) (and Double(String)) do allow a leading + sign, so perhaps BigDecimal(String) should do likewise. joshua.bloch@Eng 1998-04-30
30-04-1998

WORK AROUND The following incantation manually detects and ignores the presence of a leading + sign: BigDecimal d = new BigDecimal(s.charAt(0)='+' && s.charAt(1)!='-' ? s.substring(1) : s); joshua.bloch@Eng 1998-04-30
30-04-1998