Parsing double with suffix

Discussion in 'Java' started by Andrea Desole, Jul 7, 2005.

  1. I would generally expect the string "5" to be parses into the double
    5.0, and the string "5f" not to be parsed. However I noticed, with big
    surprise, that the string "5f" is also parsed into the double 5.0. So is
    the string "5d".
    I assume that the method parseDouble sees d and f as suffixes for the
    type float and double. In fact, all the other letters after the number
    5, including l, seem to fail.
    This looks pretty strange to me, and I would like to find a way get an
    error when parsing "5f" or "5d". Any help appreciated.
    Thanks
     
    Andrea Desole, Jul 7, 2005
    #1
    1. Advertising

  2. Andrea Desole <> writes:

    > I assume that the method parseDouble sees d and f as suffixes for
    > the type float and double. In fact, all the other letters after the
    > number 5, including l, seem to fail.


    This is as documented in Double.parseDouble()/valueOf() and section
    3.10.2 of the language specification.

    --
    For all resources, whatever it is, you need more. -- RFC 1925
     
    Juergen Nickelsen, Jul 7, 2005
    #2
    1. Advertising

  3. Juergen Nickelsen wrote:
    >
    > This is as documented in Double.parseDouble()/valueOf() and section
    > 3.10.2 of the language specification.
    >

    Damn, why don't I read the documentation of methods referred to by other
    methods' documentation.
    Thanks
     
    Andrea Desole, Jul 7, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Victor Yuan

    URL without suffix in .Net

    Victor Yuan, Dec 30, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    873
    Dino Chiesa [Microsoft]
    Jan 5, 2005
  2. GIMME
    Replies:
    2
    Views:
    877
    GIMME
    Feb 11, 2004
  3. Green

    what the suffix of the file

    Green, Oct 27, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,185
    Steven Cheng[MSFT]
    Oct 28, 2004
  4. Joseph

    compressed suffix trie

    Joseph, Sep 22, 2004, in forum: Java
    Replies:
    1
    Views:
    526
    =?ISO-8859-1?Q?Daniel_Sj=F6blom?=
    Sep 22, 2004
  5. Sydex
    Replies:
    12
    Views:
    6,508
    Victor Bazarov
    Feb 17, 2005
Loading...

Share This Page