Given a float number convert it into the string WITHOUT using any inbuilt Function

Given a float number convert it into the string WITHOUT using any inbuilt Function

Method 1:

class Float2String 
{ 
public static void main(String[] args) 
{ 
float f=7.64f; 
String result; 
result=""+f; 
System.out.println(result); 
} 
}
-by karthik dheeraj


Method 2:
float x = 7.98;
char a[5] ;
   for (int i =0; i<;4; i++){
 int m = (int)x;
 if(i==1)
    a[i] = '.';
 else 
     a[i] = m+48;
     x = x-m;
     x = x*10;
 }//for ends

    a[4] = '\0';
    string str = a;
    cout<