×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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!
  • Students Click Here

*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

Jobs

Rounding problems with my program

Rounding problems with my program

Rounding problems with my program

(OP)
At my company, we have recently gotten somebody to update our in house program written in Foxpro. We got VFP 5.0 and created a window environment. The person who did the code wrote it in I believe SQL Exec code. The problem we are having is that sometimes when the program writes to the file, it will round the data to the nearest dollar while still showing on the screen properly. It doesn't do it everytime, but enough times to be frustrating. Any ideas or suggestions would be greatly appreciated.

RE: Rounding problems with my program

Without specifics, it's hard to say where your problem might be. However, there are a few things you can look for:

1) If the program is creating a table on the fly (which is different than formatting results for screen output) and the first calculation happens to be 10 x 95, VFP sees the result as 950 and the resulting field will be created with 0 decimals. Regardless of whether subsequent calculations have more decimals, they will be rounded up. If instead, the calculation was 10.00 x 95, the result will be 950.00, and the field will have 2 decimal places. You can prove this to yourself by doing this calculation in the command window. If you are entering data on-screen, the program may be written in such a way that the operator has to enter 10.00 and not 10 to get the desired result. A little additional programming should take care of that.

2) Make sure the file structures have sufficient decimal places specified for the results you need.

3) Depending on where in the chain of events the calculations are taking place and the results are being written to a file, rounding can occur. Check through the program logic to step through the series of calculations one at a time.

I hope I've given you some ideas of where to start looking.

RE: Rounding problems with my program

One more thing to check, though if it works *some* of the time but not others, this may not be it:

If there are occurences of STR() that do not include the third parameter (decimal points), and the result is used for reports, etc, it would appear rounded in some circumstances.

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