0
double population = 7000000000;
long population2 =  7000000000;

I have to write down world population, so i used both double and long primitive types. However, both of them says that this number is out of range. What can i do with this? i made a google search but it says that long primitive type is supposed to be accepted. Can anybody please help me ?

4
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by sabbib
Featured Replies
  • 1

    What does "not accept" mean? Do you get error messages? If so, please post them. The numbers as you have written them are int values. There are suffixes you can put on a number to make it a double or long. Read More

  • > An integer literal is of type long if it ends with the letter L or l; otherwise it is of type int. It is recommended that you use the upper case letter L because the lower case letter l is hard to distinguish from the digit 1. http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html Read More

  • you used int, you need to add a 'L' at the end of the number 'l' is ok but it also looks like '1' so use 'L' for lond and 'D' for double. again 'd' works fine, it may not look like any number try to be consistant with you … Read More

1

What does "not accept" mean? Do you get error messages? If so, please post them.

The numbers as you have written them are int values. There are suffixes you can put on a number to make it a double or long.

0

The numbers as you have written them are int values. There are suffixes you can put on a number to make it a double or long.

this is the error message when i used double,

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    The literal 7000000000 of type int is out of range 

    at InterestTest.main(InterestTest.java:4)
1

you used int, you need to add a 'L' at the end of the number 'l' is ok but it also looks like '1' so use 'L' for lond and 'D' for double. again 'd' works fine, it may not look like any number try to be consistant with you case.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.