Always round fractions of a cent up!! general math issues with Crystal reports .net 9

Im using Crystal Reports 9 bundled iwth visual studio .net 2003 and i constantly lose pennies whenever it performs addition or multiplication operations of any magnitude, these add up over the course of the invoice Im creating.  seriously, it can take 150.30 * 6 and get 900.15 where the heck did the other 3 cents go.  Im confused.  Please help.  Ive tried truncation and a number of different things and nothing seems to work for me
mileyjaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

frodomanCommented:
My guess is that the number is actually 150.025 but you have the display field formatted in Crystal to only show 2 decimal places (which is the default format if you haven't changed it) so it's being seen in it's rounded form of 150.03 .  Format the field for 3 or 4 decimal places and see what the actual value in the field is.

frodoman
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mileyjaAuthor Commented:
i meant 150.03, good call frodo, ill check on that and get back to you.  Gosh your quick!!
0
mileyjaAuthor Commented:
ok, your right there, it is 150.025 so what do I need for it to make that 150.03 and truncate it, even if it was 150.021 isnt it standard procedure to always round up with fractions of a percent??
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

gopatincCommented:
I understand you want to convert 150.026 to 150.03. To do that you can use the truncate function
ex: truncate(150.025,2)

This will truncate to 2 decimal points.
But this method will truncate 150.021 - 150.025 to 150.02 and from 150.026 -150.029 to 150.03

If you want 150.021 - 150.029 to be truncated to 150.03, then use the Ceiling function
ex: Ceiling(150.025,.01)

0
mileyjaAuthor Commented:
I think iwth money arent you supposed to go up to teh next cent with any remainder, I just want it to go the next cent if there is anything more than a whole cent at all.  I understood from teh good that the truncate function throws away the extra stuff without rounding at all.  The book could be wrong I guess Ill try that at work tommarow.  But I need a function that uses the same type rounding rules as normal accounting programs.
0
gopatincCommented:
Then u should use the Ceiling function I mentioned earlier.
0
frodomanCommented:
Ceiling is a database function though, it isn't supported in Crystal 9 as far as I know.  If you can select it from your db with the ceiling function that should work.  If not, create a formula in Crystal that will do the rounding for you - but if you want it to always round up you can't use the built-in round function so I'd use this formula:

  int(({table.field} * 100) + 0.9) / 100

The you can base your summary on this formula and it will add all of the rounded numbers.


0
mileyjaAuthor Commented:
well I wasnt sure what to do.  I figured out using what I had how to get the ceiling thing to work and that was part of the original question I asked for, but I found out later all I needed was to use the standard rules of rounding (I.E. .5 or above = 1 and ect.)
In the end the tip on the extra decimals frodoman gave wound up doing it, I used a combination of truncate and round in cr9 to do it.

Truncate(Round({@FieldWithExtraDecimals}, 2), 2)

Thanks a lot guys, I had to split it.
0
frodomanCommented:
Glad to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.