• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

long q = 2342347734;

 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why do I get this error



The literal 2342347734 of type int is out of range
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you try to assign an integer literal. Turn it into a long literal and you should be fine.

A long literal ALWAYS ends with a letter L (or a lowercase l, but that's too close to a 1 in many fonts so get used to always using an uppercase L to avoid confusion).
 
vignesh hariharan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this..

long q = 2342347734L;
long q = (long)2342347734; //sorry this results the same as previous
[ May 12, 2006: Message edited by: vignesh hariharan ]
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh I see, cheers
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vignesh hariharan:
try this..
long q = (long)2342347734;


That has the same error as the original statement. Please test any suggestion before posting it.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeroen T Wenting:
A long literal ALWAYS ends with a letter L (or a lowercase l, but that's too close to a 1 in many fonts so get used to always using an uppercase L to avoid confusion).


Projects that use CheckStyle often enforce the use of uppercase L for long literals with the UpperEll check
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic