Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-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!

*Tek-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

Displaying whole number of real variable

Displaying whole number of real variable

Displaying whole number of real variable

How do I display the whole number of a real variable if the number does not have any decimal places.  I need to display the number with decimal places if it has any.


3.00 as 3
3.45 as 3.45

RE: Displaying whole number of real variable

This is actually one of the rare cases where I'd (1) use str to convert the decimal to a string with the largest number of decimal places I will ever need, then (2) check it really is a decimal by making sure pos('.', mystring) is greater than zero (and remember that not all nations use '.' as a decimal). and then (3) chew off zeroes from the right hand side until I meet a decimal point (which should also be chewed) or a non-zero digit.

But there's probably a simpler way.

RE: Displaying whole number of real variable

I think that would indeed be the best way to do it; One remark though, I think Borland Pascal always uses a dot as decimal separator, regardless of any system configuration.

Bert Vingerhoets
Don't worry what people think about you. They're too busy wondering what you think about them.

RE: Displaying whole number of real variable

... or you can use the Int() function to determine how to display the Real:

Function Whole(Source : Real) : Boolean;
  If (Int(Source) <> Source) then
    Whole := False
    Whole := True;

Good Luck  ยง;O)


RE: Displaying whole number of real variable

Thank you for you help.  I will try and use the string solution tonight.  Your help is appreciated.

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 Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

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

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close