Link to home
Start Free TrialLog in
Avatar of mileyja
mileyja

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of frodoman
frodoman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mileyja
mileyja

ASKER

i meant 150.03, good call frodo, ill check on that and get back to you.  Gosh your quick!!
Avatar of mileyja

ASKER

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??
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mileyja

ASKER

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.
Then u should use the Ceiling function I mentioned earlier.
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.


Avatar of mileyja

ASKER

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.
Glad to help.