-3

I have this string:

0.023526112354180534 

How can I transform this string to number, and maybe more digits? I tried Double.parseDouble and not work

EDIT

You are right.

I´m making a call from Javascript and my call is:

url : "/myapp/data/selectedCampaign/thermal/"+data

data=0.023526112354180534

When I entered this method in Spring

@RequestMapping(value = "/selectedCampaign/{type}/{evidenceValue}", method = RequestMethod.GET)
    public @ResponseBody List<Double> getValues(@PathVariable("type") String type,
            @PathVariable("evidenceValue") String evidenceValue)

evidenceValue is 0 and I was parsing 0

I still don t know why. EDIT 2

I reolve this issue by going to:

Spring MVC @PathVariable with dot (.) is getting truncated

Community
  • 1
  • 1
Goldbones
  • 1,407
  • 3
  • 21
  • 55

2 Answers2

2

use new BigDecimal("0.023526112354180534");

Timothy Truckle
  • 15,071
  • 2
  • 27
  • 51
1
double d = Double.parseDouble("0.023526112354180534");
System.out.println(d);

worked without problems for me at least without precision loss

Edit: As far as I know the only difference between Double.parseDouble(String) and BigDecimal is the precision, so if precision is important, you should use BigDecimal

Mein Name
  • 527
  • 3
  • 14