Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By j2me64

Thread: Java Data Types ?!

  1. #1
    Join Date
    Jul 2011
    Posts
    47
    Rep Power
    0

    Default Java Data Types ?!

    for(long a=2;a<600851475143;a++){
    vhd.Prime(a);
    }
    =================
    what can i use for 600851475143 that can support it?
    i got this error : The literal 600851475143 of type int is out of range

    i used long but it say that error again!

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default

    Try adding an L:

    600851475143L;

    to make it a long.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Join Date
    Jul 2011
    Posts
    47
    Rep Power
    0

    Default

    Thx...It Worked...
    but why without L it didn't work?

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

  5. #5
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by HearT.Hunt3r View Post
    Thx...It Worked...
    but why without L it didn't work?
    because the compiler reads integer literals as Integers types, and decimal literals as Decimal. So if you need a Float type you must use a F ex. 2.0F
    HearT.Hunt3r likes this.

Similar Threads

  1. primitive Data types
    By Manfizy in forum New To Java
    Replies: 2
    Last Post: 07-07-2009, 08:29 PM
  2. Array of different data types?
    By venkatteshb in forum New To Java
    Replies: 1
    Last Post: 08-27-2008, 05:42 PM
  3. Primitive data types of Java
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-28-2008, 07:29 PM
  4. Converting data types
    By bluekswing in forum New To Java
    Replies: 4
    Last Post: 01-12-2008, 12:48 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
  •