Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Character Values Inside of Number Values

  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    182
    My Mood
    Where
    Thanks
    15
    Thanked 8 Times in 8 Posts

    Default Character Values Inside of Number Values

    I am curious... the Java API is able to return the apparent String "NaN" as a double value for non-real calculations.

    How can one include characters in a double value?

    Say if you wanted to design an implementation of imaginaries in Java, you would need to be able to have "i" in a value, how can you make 2i a valid Number?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Character Values Inside of Number Values

    NaN is not a string, but a constant double value (read the API on Double for the value). There are many implementations on complex number math - google these terms for the examples.

  3. #3
    Member
    Join Date
    Jun 2011
    Posts
    182
    My Mood
    Where
    Thanks
    15
    Thanked 8 Times in 8 Posts

    Default Re: Character Values Inside of Number Values

    Quote Originally Posted by copeg View Post
    NaN is not a string, but a constant double value (read the API on Double for the value). There are many implementations on complex number math - google these terms for the examples.
    I have tried using the Double.longBitsToDouble method to convert a character to double but no matter what I pass it, it won't return the character.

    I have tried passing the character's bit value and hexadecimal. Both do not return a letter.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Character Values Inside of Number Values

    Quote Originally Posted by bgroenks96 View Post
    I have tried using the Double.longBitsToDouble method to convert a character to double but no matter what I pass it, it won't return the character.

    I have tried passing the character's bit value and hexadecimal. Both do not return a letter.
    See the API for double....Double.longBitsToDouble returns a double, not a character.

  5. #5
    Member
    Join Date
    Jun 2011
    Posts
    182
    My Mood
    Where
    Thanks
    15
    Thanked 8 Times in 8 Posts

    Default Re: Character Values Inside of Number Values

    But the value NaN prints as "NaN"

    How can you define something as a double value, when it has a character form in print?

Similar Threads

  1. Replies: 5
    Last Post: April 22nd, 2013, 07:27 AM
  2. Junk values
    By abhilash.naik in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: September 9th, 2010, 06:25 AM
  3. Able to set, but not get values
    By Simple in forum What's Wrong With My Code?
    Replies: 18
    Last Post: June 23rd, 2010, 04:01 PM
  4. need to know if the object is a number or character
    By karneson05 in forum Java SE APIs
    Replies: 8
    Last Post: November 27th, 2009, 11:24 AM
  5. Values of Input
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: November 8th, 2009, 03:46 AM