Java newbie help (type casting, 64bit unsigned Long)

Discussion in 'Java' started by hochidsp@gmail.com, Mar 23, 2005.

  1. Guest

    Hi I am java newbie and need help on my project. I have a few
    questions. Can you put strings in a hashtable and test for their being
    their with the appropriate hashtable method? I want to test for equal
    strings, not the same object. Second question can you use all 64 bits
    of an unsigned long? java doesn't seem to allow this. Any packages that
    do?
    Thanks,
    Dave
     
    , Mar 23, 2005
    #1
    1. Advertising

  2. wrote:
    > Hi I am java newbie and need help on my project. I have a few
    > questions. Can you put strings in a hashtable and test for their being
    > their with the appropriate hashtable method? I want to test for equal
    > strings, not the same object. Second question can you use all 64 bits
    > of an unsigned long? java doesn't seem to allow this. Any packages that
    > do?
    > Thanks,
    > Dave
    >


    Any object can be used as either the Key or Value. The String object's
    equals() method will be used to determine whether the search key is
    found within the key set. Google Java String to see what the equals()
    method does.

    Java does not support unsigned longs or ints - they are all signed.

    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html

    If you need a bigger number than a (signed) long, then one way is to use
    an array of bytes.
     
    Andrew McDonagh, Mar 23, 2005
    #2
    1. Advertising

  3. Andrew McDonagh wrote:
    >
    > wrote:
    > > Hi I am java newbie and need help on my project. I have a few
    > > questions. Can you put strings in a hashtable and test for their being
    > > their with the appropriate hashtable method? I want to test for equal
    > > strings, not the same object. Second question can you use all 64 bits
    > > of an unsigned long? java doesn't seem to allow this. Any packages that
    > > do?

    >
    > Any object can be used as either the Key or Value. The String object's
    > equals() method will be used to determine whether the search key is
    > found within the key set. Google Java String to see what the equals()
    > method does.
    >
    > Java does not support unsigned longs or ints - they are all signed.
    >
    > http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html
    >
    > If you need a bigger number than a (signed) long, then one way is to use
    > an array of bytes.


    Try java.math.BigInteger. It's signed but you can values greater than 32-bits.

    --
    Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
    ==============================================================
    * The Ultimate DBMS is here!
    * FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
     
    Lee Fesperman, Mar 24, 2005
    #3
  4. Chris Smith Guest

    <> wrote:
    > Second question can you use all 64 bits
    > of an unsigned long? java doesn't seem to allow this.


    Here's a slight modification to the answers you've already received.
    Java has a 64-bit integer data type. Various operators and API
    functions may treat it as either signed or unsigned, or they may work
    with either. Something about your phrasing suggests that you want to
    use the long as a bit mask... in that case, all operators are
    independent of sign, except that >>> should be used instead of >>.

    --
    www.designacourse.com
    The Easiest Way To Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Mar 24, 2005
    #4
    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. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    755
    Eric Sosman
    Jul 8, 2003
  2. curious_one

    Casting (signed long)(unsigned long)

    curious_one, Jan 30, 2004, in forum: C Programming
    Replies:
    5
    Views:
    692
  3. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,248
    Peter Shaggy Haywood
    Sep 20, 2005
  4. TK
    Replies:
    3
    Views:
    447
  5. Alex Vinokur
    Replies:
    9
    Views:
    834
    James Kanze
    Oct 13, 2008
Loading...

Share This Page