java - How to get two value after the decimal for the result of distance -



java - How to get two value after the decimal for the result of distance -

to calculate distance between 2 places;with 2 lat , longi using link calculate distance in meters when know longitude , latitude in java

i got result metre 2.4737676e-5,its float value too.

i want take first 2 values after decimal.but using decimal format , string format couldn't expected result like(2.47)..its coming 0.00 only.

> float meanwhiledist=distfrom(latti,longii,curlat,curlongi); > decimalformat df2 = new decimalformat( "#.00"); > double dd2dec = new double(df2.format(meanwhiledist)); or double dd = double.valueof(meanwhiledist); string angleformated = string.format("%.2f", dd); if print angleformated , dd2dec result coming 0.00

the value of 2.4737676e-5 seems less expect:

float ff= 2.4737676e-5f; system.out.println("float value: "+ff); double dd=double.valueof(ff); system.out.println("double value: "+dd); bigdecimal test=new bigdecimal(dd); system.out.println("big decimal value: "+test); string angleformatted=test.tostring(); system.out.println("string value: "+angleformatted);

output:

float value: 2.4737676e-5 double value: 2.4737675630603917e-5 big decimal value: 0.000024737675630603916943073272705078125 string value: 0.000024737675630603916943073272705078125

the output right since returns first 2 decimal places 0.000.....

java android decimalformat

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -