hello
how to convert string to double, and result is string.
example ;
String code =00000000001;
Double plus =code + 1;
String result =plus; // and result is 0000000002

thanks

I'm quite sure 5 mins of google will solve this problem for you.

Have this as example.......

class doubconv
{
public static void main(String args[])
{
String code="00000000001";
double dbl=Double.parseDouble(code);
double dbl1=dbl+1;
String result=dbl1+"";

System.out.println(result);

}
}

Awwwwwwwww, but how do I get the leading zeroes back?! Will be his next post.

if you have better way more than this means please show your solutions also. it will be really useful

class doubconv
{
public static void main(String args[])
{
String code="00000000001";
int leng=code.length();
int cnt=0;
for(int j=0;j<leng;j++)
{
char c=code.charAt(j);
if(c=='0')
{
cnt++;

}
else
{
break;
}
System.out.println(cnt);
}
String si="";
for (int k=0;k<cnt ;k++ )
{
si=si+"0";
}
double dbl=Double.parseDouble(code);
double dbl1=dbl+1;

String result=si+dbl1+"";

System.out.println(result);

}
}

hello,
String s1=new String("0000001");
Double d=new Double(s1);
double d1=d.doubleValue();
s1=d1+"";
if u solve ur problem plz give a reply. i hopw u will solve ur problem by using this simple logic

I am almost sure that you are doing all this for display purposes. If so, then why not just use the formatting provided by the printf method.

``````int i = 1;
System.out.printf("%010d%n", i);
i += 10;
System.out.printf("%010d%n", i);``````

That or use NumberFormat.
To any sane person (and a computer in that regard is a sane person) the leading zeros are utterly unimportant, a darned nuisance even, and thus stripped and ignored.

None of you except sos realised that apparently. None of you took the trouble to actually look at how numbers are represented in a computer, and thus realised that there are no leading zeros anywhere.
The number is stored as a series of bits representing a number, NOT a string, and a number never has leading zeros.

That or use NumberFormat.
To any sane person (and a computer in that regard is a sane person) the leading zeros are utterly unimportant, a darned nuisance even, and thus stripped and ignored.

None of you except sos realised that apparently. None of you took the trouble to actually look at how numbers are represented in a computer, and thus realised that there are no leading zeros anywhere.
The number is stored as a series of bits representing a number, NOT a string, and a number never has leading zeros.

Obviously my posts were facetious. This idoicy of storing a double as a string and converting back and forth to do math with it is just that, idoicy. Obviously you simply use (and store) a double as a double and format the output as you want it, when it comes time to produce output, and not before. Anything else, is, as already stated, idiocy.