java - Rounding off digit and decimals to Nearest Hundred -


hi have scenarios in

i have verify integer 35.0k 34995

i converting 35.0 35000

string str = new double(casha).tostring().substring(0,casha.indexof('.')); int org=integer.parseint(str); org=org*1000; 

in have rounded off 34995 35000 in java program

i got doing

int rounded = ((34995+ 99) / 100 ) * 100; if(org==rounded){ system.out.println("pass"); }else  { system.out.println("fail"); } 

which result in 35000 , verifying

but not work values 147.7k(147700) , 147661(147000) 147000 

how can compare values 147.7k 123.2k how convert .7 , 2. hundreds.

please help,

thanks.

here way .7 , .2

string numberstring = "123.4k"; numberstring = numberstring.replace("k", ""); double numberdouble = new double(numberstring)*1000; integer numberinteger = numberdouble.intvalue(); system.out.println(numberinteger); 

output:

123400 

so, after this, can run approximation on both numbers , see match.

also, recommend looking @ link provided in comments


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -