Range of Long type doesn磘 fit

Hi!!!

I am trying to assign the following value to a variable of type long

long A = -140737488355327;

The compiler tells me that such integer number is too large. I can磘 assign it to A.

Sun磗 tutorial tells that long variables can hold a minimum value of

-9,223,372,036,854,775,808. In my case it is not working... Somebody help?

[366 byte] By [charlles_cubaa] at [2007-11-26 23:51:55]
# 1
Try long A = -140737488355327;
annie79a at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...
# 2
It didn磘 work eitherThanks
charlles_cubaa at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...
# 3
This works for me :long A = -140737488355327L; (note the L at the end)
armalcolma at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...
# 4
An integer literal that does not end with lower- or uppercase L is considered to be an int. That number is too big for an int. If you want the literal to be a long, append an L.
jverda at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...
# 5
Yeahhh it worked...But why the L in the end?Thanxssss
charlles_cubaa at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...
# 6
> Try > long A = -140737488355327;This stupid forum chops of the L, so you have to double it up.-140737488355327L becomes -140737488355327and -140737488355327LL becomes -140737488355327L
jverda at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...
# 7
See JVerds reply above. The literal won't fit in an int, so you need the L to tell the complier that the literal is a long value.
armalcolma at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...
# 8

> Yeahhh it worked...

> But why the L in the end?

> Thanxssss

It means long. Without it, it'll be interpreted as an int (which doesn't fit).

Note that Annie's already posted the correct answer, but the buggy forum software eats the trailing L from within code tags (if you quote her reply, you'll see the L again).

prometheuzza at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...
# 9
Ok thanks everybody I got..[]磗
charlles_cubaa at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...
# 10

> Note that Annie's already posted the correct answer,

> but the buggy forum software eats the trailing

> L from within code tags (if you quote her

> reply, you'll see the L again).

So I see nothing's changes around here. Should I be surprised? :)

annie79a at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...
# 11
> ...> So I see nothing's changes around here. Should I be> surprised? :)I know you're not!; )
prometheuzza at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...
# 12
Thanks Annie. when I post you gave me a prompt answer.But the ******* buggy forum ate your trailing L Thnks anyway;)
charlles_cubaa at 2007-7-11 15:31:08 > top of Java-index,Java Essentials,Java Programming...