6 Replies Latest reply on Dec 17, 2007 8:25 PM by 807601

# put number 10e12 into "long"

hi
I want to do this:
``long MaxN = 10e12;``
nothing difficult, but java compiler says: "possible loss of precision; found: double, required: long"

so is it possible to put number 10e12 into long? i tried to write:
``long MaxN = 1000000000000;``
but compiler replied: "integer number too large"
thanks
• ###### 1. Re: put number 10e12 into "long"
``long MaxN = 1000000000000;``
``long MaxN = 1000000000000L;``
• ###### 2. Re: put number 10e12 into "long"
hmm
just one letter...
thanks :)
• ###### 3. Re: put number 10e12 into "long"
I hate it when literals that long end up in code. I have to squint and count zeros. I would prefer:
``long MAX = 1000 * 1000 * 1000 * 1000L;``
or some other factoring that makes sense in the context. (Note that the L is still needed -- check and see what happens without it ;-)
• ###### 4. Re: put number 10e12 into "long"
DrLaszloJamf wrote:
I hate it when literals that long end up in code. I have to squint and count zeros. I would prefer:
``long MAX = 1000 * 1000 * 1000 * 1000L;``
or some other factoring that makes sense in the context. (Note that the L is still needed -- check and see what happens without it ;-)
And if you're going to do something like this, put the "L" on the first constant, not the last. It's okay in the above example, but if you insert another "* 1000" into that expression it won't work.
• ###### 5. Re: put number 10e12 into "long"
You're right. L's all around!
• ###### 6. Re: put number 10e12 into "long"
also note that "10e12" means 10 * 10^12, which is 10^13

you probably meant "1e12"