how to use unsinged long in java

N

Navneet Mathpal

hi
I wnat to store 20141231246023 but long is out of range in it.
how to save value in this range.
is there any unSigned long available??

I was trying unSigned long but not working ..
 
L

Lew

I wnat to store 20141231246023 but long is out of range in it.
how to save value in this range.
is there any unSigned long available??
No.

I was trying unSigned long but not working ..

That should not surprise you.

Would 'java.math.BigInteger' help you?
 
V

Volker Borchert

Navneet said:
I wnat to store 20141231246023 but long is out of range in it.
how to save value in this range.

???

long is signed 64bit: -9223372036854775808 ... 9223372036854775807

If that's too small, use java.math.BigInteger or roll your own
fixed size type consisting of two or four or eight long.
 
J

Joerg Meier

That should not surprise you.

It surprises me how many people apparently learn to program by randomly
typing words into their text editor until one turns out to coincidentally
be something the compiler recognizes. It's like learning a second language
by pressing random letters until Word stops putting red squigglies under a
word.

Liebe Gruesse,
Joerg
 
E

Eric Sosman

hi
I wnat to store 20141231246023 but long is out of range in it.

No, the value is well within the range of `long'. The problem
is that it's *not* within the range of `int', so you cannot write
the value as an `int' constant. Use 20141231246023L to write a
`long' constant.
how to save value in this range.
is there any unSigned long available??

No.
 
M

markspace

It surprises me how many people apparently learn to program by randomly
typing words into their text editor until one turns out to coincidentally
be something the compiler recognizes.


Well all those Perl programmer got started somehow.
 
M

Marcel Müller

I wnat to store 20141231246023 but long is out of range in it.
how to save value in this range.

As others said, long is fine.

But I really cannot recommend to use integers for human readable time
stamps. SAP does this and it is the source of problems all the time.
- The types provides the operators +, -, *, /, % without any reasonable
result.
- It can represent inconsistent time stamps like Feb 31th.
- Accessing the fields cause the same number of divisions than with a
linear representation like with java.util.Date.
- And some visualizations end up with 20,141,231,246,023 which is
entirely unreadable.


Marcel
 
A

Arivald

W dniu 2014-03-14 11:40, Joerg Meier pisze:
It surprises me how many people apparently learn to program by randomly
typing words into their text editor until one turns out to coincidentally
be something the compiler recognizes. It's like learning a second language
by pressing random letters until Word stops putting red squigglies under a
word.

Not really. If someone have experience in C++ or other languages, it is
natural to try same type names, expecting them.
 
L

Lew

Arivald said:
Joerg Meier pisze:
Lew said:
The OP wrote:]
I was trying unSigned long but not working ..
That should not surprise you.
It surprises me how many people apparently learn to program by randomly
typing words into their text editor until one turns out to coincidentally
be something the compiler recognizes. It's like learning a second language
by pressing random letters until Word stops putting red squigglies under a
word.

Not really. If someone have experience in C++ or other languages, it is
natural to try same type names, expecting them.

Sure, insofar as it's "natural" to try anything utterly stupid.

Here's what's natural to actual computer programmers: looking it up.

For God's sake, the primitive type names are the most, well, primitive facts about the language!

And you make excuses for that baloney?

There's something unnatural there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top