Can beanshell handle numbers > 2^32?

classic Classic list List threaded Threaded
4 messages Options
mb5
Reply | Threaded
Open this post in threaded view
|

Can beanshell handle numbers > 2^32?

mb5

When I try to use large numbers with Beanshell I get an evaluation error.

The code,
                Long userSessionID = 3628659048681585783;

will result in,

"Evaluation Error: Parse error at line 41, column 38 : Error or number too
big for integer type: 87417309615"

How can I use numbers > 2^32 with Beanshell?

.mattias
--
View this message in context: http://www.nabble.com/Can-beanshell-handle-numbers-%3E-2%5E32--tf3558696.html#a9937391
Sent from the BeanShell - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Can beanshell handle numbers > 2^32?

Marcel.

This works:
long userSessionID = 3628659048681585783L;
print(userSessionID);

You can also have a look at the BigInteger class for >64 bit !
import java.math.BigInteger;
BigInteger avalue = new BigInteger( "1254565590153556789012534" );
print(avalue);
http://mindprod.com/jgloss/biginteger.html
--
View this message in context: http://www.nabble.com/Can-beanshell-handle-numbers-%3E-2%5E32--tf3558696.html#a9937977
Sent from the BeanShell - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
mb5
Reply | Threaded
Open this post in threaded view
|

Re: Can beanshell handle numbers > 2^32?

mb5
In reply to this post by mb5


Yeah, it works like a charm after inserting the missing 'L'.

Thanks!
--
View this message in context: http://www.nabble.com/Can-beanshell-handle-numbers-%3E-2%5E32--tf3558696.html#a9938818
Sent from the BeanShell - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Can beanshell handle numbers > 2^32?

Alexey Zinger
In reply to this post by mb5
You're using an int literal that you're then implicitly forcing BeanShell to cast into Long.  That value is too big for int, which is why you're getting the error.  Instead, you should be using a long literal to begin with:

3628659048681585783L
^ note the L


mb5 <[hidden email]> wrote:

When I try to use large numbers with Beanshell I get an evaluation error.

The code,
Long userSessionID = 3628659048681585783;

will result in,

"Evaluation Error: Parse error at line 41, column 38 : Error or number too
big for integer type: 87417309615"

How can I use numbers > 2^32 with Beanshell?

.mattias
--
View this message in context: http://www.nabble.com/Can-beanshell-handle-numbers-%3E-2%5E32--tf3558696.html#a9937391
Sent from the BeanShell - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users



Alexey
2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500
http://azinger.blogspot.com
http://bsheet.sourceforge.net
http://wcollage.sourceforge.net


Ahhh...imagining that irresistible "new car" smell?
Check out new cars at Yahoo! Autos.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users