×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• 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.

# Displaying whole number of real variable

## Displaying whole number of real variable

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

Ex.

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.

Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
http://student.vub.ac.be/~bvingerh/
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;
Begin
If (Int(Source) <> Source) then
Whole := False
Else
Whole := True;
End;

Good Luck  ยง;O)

Jakob

### RE: Displaying whole number of real variable

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

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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!