troubleshooting Question

How to validate max and min of Long and BigDecimal data type

Avatar of william007
william007 asked on
JavaJava EE
16 Comments4 Solutions1001 ViewsLast Modified:
1. Hi, I need to read the input from the user and use Long.parseLong() to parse it to long datatype.
However, before parsing, I wish to check whether the user has entered the value greater than the max value of long (2^63-1) or smaller than min value of long(-2^63), how to do this?

2. The same question go to BigDecimal. By the way, what is the max and min value for BigDecimal?

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 4 Answers and 16 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros