×

# Conversion from integer/floating-point to string

 0 Please tell me how can I convert integers such as 5,7,89,etc. or floating-ppoints like 5.90,7.45,etc. to strings like "5","5.90",etc. asked 07 Mar '15, 19:32 469●5●29 accept rate: 7%

 0 Hello Anupam, it's very easy to convert ..take a look at this code below. class Conversion{  public static void main(String args[]){ int x= 2; float y = 2.95; String str_int = 2+""; String str_float = 2.95+""; //now you can print it.. System.out.println("Int to String "+str_int+" Float to String "+str_float); }  } answered 07 Mar '15, 19:48 1●4 accept rate: 0%
 0 This might be of your use, http://ideone.com/NjqIMR Jst using basic sprintf() function. answered 07 Mar '15, 19:58 3★damn_me 2.6k●2●13●36 accept rate: 24%
 0 As I am new to the site, I did not see what language you wanted this in so I am going to post what I would do in C++. Since C++ 11 has a new function of putting things to strings, see code below, it is easier to convert things now! #include int a = 12; float b = 3.1459; std::string str = to_string(a); std::string str2 = to_string(b);  answered 07 Mar '15, 20:05 1 accept rate: 0%
 0 I want the code in c++4.3.2 answered 07 Mar '15, 20:43 469●5●29 accept rate: 7%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×17

question asked: 07 Mar '15, 19:32

question was seen: 1,457 times

last updated: 07 Mar '15, 20:43