title: Conversion of numeric to string in MATLAB
body: <p>Suppose I want to conver the number <code>0.011124325465476454</code> to string in MATLAB.</p>
  
  <p>If I hit</p>
  
  <p><code>mat2str(0.011124325465476454,100)</code></p>
  
  <p>I get <code>0.011124325465476453</code> which differs in the last digit.</p>
  
  <p>If I hit <code>num2str(0.011124325465476454,'%5.25f')</code></p>
  
  <p>I get <code>0.0111243254654764530000000</code></p>
  
  <p>which is padded with undesirable zeros and differs in the last digit (3 should be 4).</p>
  
  <p>I need a way to convert numerics with random number of decimals to their EXACT string matches (no zeros padded, no final digit modification).</p>
  
  <p>Is there such as way?</p>
  
  <p>EDIT: Since I din't have in mind the info about precision that Amro and nrz provided, I am adding some more additional info about the problem. The numbers I actually need to convert come from a C++ program that outputs them to a txt file and they are all of the C++ <code>double</code> type. [NOTE: The part that inputs the numbers from the txt file to MATLAB is not coded by me and I'm actually not allowed to modify it to keep the numbers as strings without converting them to numerics. I only have access to this code's "output" which is the numerics I'd like to convert]. So far I haven't gotten numbers with more than 17 decimals (NOTE: consequently the example provided above, with 18 decimals, is not very indicative).</p>
  
  <p>Now, if the number has 15 digits eg 0.280783055069002</p>
  
  <p>then <code>num2str(0.280783055069002,'%5.17f')</code> or <code>mat2str(0.280783055069002,17)</code> returns</p>
  
  <p><code>0.28078305506900197</code></p>
  
  <p>which is not the exact number (see last digits).</p>
  
  <p>But if I hit  <code>mat2str(0.280783055069002,15)</code> I get</p>
  
  <p><code>0.280783055069002</code> which is correct!!!</p>
  
  <p>Probably there a million ways to "code around" the problem (eg create a routine that does the conversion), but isn't there some way using the standard built-in MATLAB's to get desirable results when I input a number with random number of decimals (but no more than 17);</p>