Originally posted by Eviano Afiemo:
However, my compiler gives me the following error " Literal overflows capacity of int type ...":
The only way of performing such a calculation is by appending L to the value to indicate
that it is of type long.
i.e 555444333222L / 1000000000000L .
However since the number will actually be a variable, I somehow need to pass it into methods as a an argument without the expression above falling flat on its face.
Originally posted by Eviano Afiemo:
... type long.
i.e 555444333222L / 1000000000000L .
However since the number will actually be a variable, I somehow need to pass it into methods as a an argument without the expression above falling flat on its face.
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
long number = 555444333222L / 1000000000000L
??
Originally posted by Eviano Afiemo:
Marilyn I read in a book, that Java defaults to integers for number literals, and the only way to let the compiler know that you're dealing with a long is by appending an "L" to the end of the number. That's why the above code works.
[/list]
I'll probably have to go with Dan's suggetion (breaking the number in to chunks).
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Originally posted by Marilyn deQueiroz:
By the way, do you know what the possible range of values is for an int?
Consider Paul's rocket mass heater. |