Results 1 to 5 of 5
  1. #1
    yatin.baraiya is offline Member
    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Question DecimalFormat fromat method return junk chacter , formate with this value "NaN"

    Hello all
    I get the following issue when i use the DecimalFormat java class for format the value in java program,

    Below is my the java code
    String pattern = "0";
    String value[] = new String[1];
    value[0] = "NaN";
    DecimalFormat myFormatter = new DecimalFormat(pattern);
    value[0] = myFormatter.format(Double.parseDouble(value[0]));
    Here when my java consol can not print the value[0] , When i had debug it and check its value is display as small square in debug console
    while in html page its value display is like this character �.

    So how can i format the "NaN" Value? actually i think it is meaningless to format the "NaN" value , but i want to know
    why the below code is return junk character value.
    value[0] = myFormatter.format(Double.parseDouble(value[0]));

    Pls provide me the proper solution of my above case.

    Thanks in advance
    Yatin Baraiya

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: DecimalFormat fromat method return junk chacter , formate with this value "NaN"

    Where does the one-element String array figure in your problem? Why didn't you use a simple String variable?

    Or did you think it might be fun to obscure the real issue with something irrelevant?

    Also, go through
    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default Re: DecimalFormat fromat method return junk chacter , formate with this value "NaN"

    That's just the way how it formats a NaN value; it formats infinity as ∞ b.t.w.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    yatin.baraiya is offline Member
    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Question Re: DecimalFormat fromat method return junk chacter , formate with this value "NaN"

    Quote Originally Posted by DarrylBurke View Post
    Where does the one-element String array figure in your problem? Why didn't you use a simple String variable?

    Or did you think it might be fun to obscure the real issue with something irrelevant?

    Also, go through
    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum

    db

    Hy DarrylBurke,

    i have check it with simple String variable, but still it gives me the junk character, i want to know why DecimalFormat format method return junk chacter when i format the 'NaN' value?

    Thanks and Regards
    Yatin Baraiya

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default Re: DecimalFormat fromat method return junk chacter , formate with this value "NaN"

    Of course reply #3 was entirely written in invisible ink ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 17
    Last Post: 05-28-2012, 08:30 PM
  2. Simple "Global" function to return random int
    By mac666 in forum New To Java
    Replies: 2
    Last Post: 01-10-2012, 03:13 PM
  3. Getting more than one "return" from a method
    By Mapisto in forum New To Java
    Replies: 49
    Last Post: 12-17-2011, 11:01 PM
  4. Replies: 3
    Last Post: 05-25-2009, 08:50 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •