storing java float/double as a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • veremue
    New Member
    • Mar 2007
    • 14

    #1

    storing java float/double as a string

    I want to store a float/double as String. I have an input file with a column with float values i.e. have the form 1.4E15. I want to store these values as Strings. Here is my code which is resulting in storing 1.4E15 not the value as a String.

    [code=java]

    String accNumber="";//declaring and initialisation

    //open file and read line then store the column in accNumber
    //the line read has been stored into an array String split[]

    accNumber=split[2].trim();

    //how do I make sure it does not store 1.4E15[/code]
    Last edited by Ganon11; Oct 7 '07, 04:26 PM. Reason: Fixing [CODE] tags.
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by veremue
    I want to store a float/double as String. I have an input file with a column with float values i.e. have the form 1.4E15. I want to store these values as Strings. Here is my code which is resulting in storing 1.4E15 not the value as a String.

    [code=java]

    String accNumber="";//declaring and initialisation

    //open file and read line then store the column in accNumber
    //the line read has been stored into an array String split[]

    accNumber=split[2].trim();

    //how do I make sure it does not store 1.4E15[/code]

    Look at this Code.

    [code=java]
    double d = 1.4E15;
    BigDecimal bd = new BigDecimal(d);
    System.out.prin tln(bd.toPlainS tring());
    [/code]

    Debasis Jana

    Comment

    Working...