×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Itos Function

Itos Function

Itos Function

(OP)
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

RE: Itos Function

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
www.infotechpr.net

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources