Solved

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

Posted on 2006-04-12
877 Views
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
0
Question by:mileyja

LVL 42

Accepted Solution

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

Author Comment

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

Author Comment

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

LVL 5

Assisted Solution

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

Author Comment

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

LVL 5

Expert Comment

Then u should use the Ceiling function I mentioned earlier.
0

LVL 42

Expert Comment

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

Author Comment

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.

Thanks a lot guys, I had to split it.
0

LVL 42

Expert Comment

0

## Featured Post

### Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…