cancel
Showing results for 
Search instead for 
Did you mean: 

How Crystal represents currency

Former Member
0 Kudos

Crystal Reports XI

When you tell crystal to convert number to Currency, is the result represented as a floating point number?

I'm trying to figure out if I have to worry about rounding error when taking the sum of a field formula that has a value like "CCur ({Get_RptCashCounts;1.Amount})"

I think the answer was in a pdf still indexed on google, but I can't hunt any basic documentation down now:

support.businessobjects.com/documentation/product_guides/boexi/en/crxi_Techref_en.pdf

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Raghavendra, rounding is what I'm getting at. All of my data represents real exact numbers of dollars and pennies. My point is, if Crystal stores $12.34 as a double, and as 12 point 34, it can't possibly store the 34 part accurately. But maybe it stores it as one thousand, two hundred thirty four. And stores the position of the decimal point separately from the number. That's what I hope, but I doubt it.

The document Fritz pointed me to seems to be telling me that in the API you always treat currency as a double precision floating point value. The Crystal Users Guide XI doesn't say anything about data representation that I could find, just how Crystal will visually format numbers when displaying, which is irrelevant to the question at hand.

Maybe another way to ask the question is: does Crystal have any number type that is not floating point?

So anyway, if all numbers are doubles, and since all my numbers represent whole pennies, I think I could do accurate math, barring possibility of large value overflow, with:

Multiply field value by 100.

Round that to zero decimal places. Now it is exact number

Sum up the rounded numbers

Divide by 100. Now there is usually rounding error, but it will never be significant - there' s no opportunity to add up rounding error.

Treat the result as currency

Thanks,

Levin

Former Member
0 Kudos

this rounding formula may be what you are looking for

(if (remainder({@pallet count}, 1) > 0 and

remainder({@pallet count}, 1) < 1) then

truncate({@pallet count}) + 1

else {@pallet count})

fritzfeltus
Product and Topic Expert
Product and Topic Expert
0 Kudos

The new location for the PDF you found is here:

http://help.sap.com/businessobject/product_guides/boexi/en/crXI_Techref_en.pdf

You can find all documentation on help.sap.com.

Former Member
0 Kudos

Right, but if currency is stored as a double, and you have bad luck, using sum() on the fields might give you the wrong answer. Say that $0.01, in it's internal representation, is stored as .0100000001. And you run a report with a billion fields equal "about" .01. Then you sum them up. If it's stored as a double, you get not 10 million but one billion times .010000001

Thanks, though - but I'm not concerned about the format right now, just whether it's stored as a precise number or as floating point.

Former Member
0 Kudos

What happens if you select th format type 11233.0000?

If you have more decimals then click on custom button and select the rounding factor. After changing the format try changing the format for your summary field also.

Regards,

Raghavendra

Former Member
0 Kudos

When you try to convert to Currency then it converts the number(123) like $123.00.

You can also use format field by placing the field on the report and right click go to format field>Number>select the format and check the display currency symbol check box.

Regards,

Raghavendra