Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Itos Function

Status
Not open for further replies.

MuzamilEETC

Mechanical
Nov 16, 2010
31
0
0
JP
Hi,

As we know Itos function used to convert Integer to string. When we use this to a Real number having 14 decimal values it round off to a single digit. Can we use this to show as 2 decimal places.

Ceil and floor maintains the integer data type requirement is to convert to string and change from 14 to 2 decimal places.

Thanks and regards
Muzamil
 
Replies continue below

Recommended for you

I have done this in the past. The approach is to first make a string variable equal to the integer portion of the real number plus a "." (or comma if using metric). Then you take the portion of the real number after the decimal point and multiply it by 10 and take the integer portion if it is 1 or more and addit to the right of the period. This would be continued up to the number of decimal places desired. Be sure to add code to get the number rounded off for the last decimal place.

Peter Stockhausen
Senior Design Analyst (Checker)
Infotech Aerospace Services
 
Status
Not open for further replies.
Back
Top