Results 1 to 4 of 4
  1. #1
    gbtimmon is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default Declaring a long

    I'm putting this in new to Java because i feel like an idiot not being able to figure it out but i by no means consider myself new to java, haha.

    for some reason i cant get eclipse to declare a long that is larger than an int,
    the code
    Java Code:
    long something = 2147483647;
    works but
    Java Code:
    long somethingElse = 2147483648;
    does not, an returns an error message that it is out of bounds for an int.

    however if i write
    Java Code:
    long something = 2147483647;
    something += 1;
    then something will properly return 2147483648, which is out of int range.
    so eclipse is constructing a long properly but for some reason wont let me initialize it beyond an int.
    I suppose i could just do some kind of load upper/lower immediate set up where i initialize the variables in pieces, however this is a pain in the ass, especially since i'm work on multiple integers somewhere in the range of 10^21, and i don't know why it wont let me initialize.

    Any ideas?, is there some fundamental way to do this that i have just forgotten over the years?

    thanks for the help.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    gbtimmon is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    thanks, that was it.
    I can't remember the last time i had to explicitly declare a long like that, so i guess i just forgot how.

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

    Default

    Quote Originally Posted by gbtimmon View Post
    thanks, that was it.
    I can't remember the last time i had to explicitly declare a long like that, so i guess i just forgot how.
    So it wasn't Eclipse's fault. It correctly detected that you literal int was too large to fit in an int. Remember: it is always our own fault, only in highly exceptional circumstances it's the fault of some industrial strength piece of software.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. declaring Classes
    By danderton in forum Java Applets
    Replies: 14
    Last Post: 07-27-2010, 01:29 PM
  2. Declaring URL object
    By TheFlying_Boy in forum New To Java
    Replies: 6
    Last Post: 08-03-2009, 07:05 PM
  3. Declaring variables
    By Flashmatix in forum New To Java
    Replies: 12
    Last Post: 01-20-2009, 03:43 PM
  4. Declaring a Queue
    By rhm54 in forum New To Java
    Replies: 1
    Last Post: 03-21-2008, 05:02 AM
  5. Declaring an ArrayList
    By bugger in forum New To Java
    Replies: 3
    Last Post: 01-31-2008, 07:36 PM

Posting Permissions

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