troubleshooting Question

restrict decimal places for double datatype

Avatar of PearlJamFanatic
PearlJamFanatic asked on
10 Comments2 Solutions175 ViewsLast Modified:
I have java code that uses double type. I am using a sdk util function to round and restrict the decimal to 2 place. something like:
openCurrentBar=Util.round(localDataSeries.getOpen(paramInt), 2);
highCurrentBar=Util.round(localDataSeries.getHigh(paramInt), 2);
lowCurrentBar=Util.round(localDataSeries.getLow(paramInt), 2);
It does fix the issue temporarily but later in the code these variables show value of 11 digit decimal places again. This happens when they are used for calculation. How can I restrict the decimal paces permanently to 2 digits only such that no matter what happens in the code it does not show more than 2 digits. openCurrentBar should be something like 2365.21 and NOT 2365.213456721309.
Join our community to see this answer!
Unlock 2 Answers and 10 Comments.
Start Free Trial
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 2 Answers and 10 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