Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Currency multiplication and precision 2

Status
Not open for further replies.

kj27

Programmer
Mar 16, 2010
30
US
Hello Folks,

I have a question regarding curency conversion (exchange rate) and precision. I have the exchange rate coming into the report as a string (i.e. "0.07654"). I would need to multiply this in a formula with a database field (SQL Server NUMBER type). The only problem is that when using CDbl() or CCur(), rounding occurs and the exchange rate becomes: 0.08.

Is there a way to maintain/specify precision when converting from string to a number or currency?

Thanks in advance!
 
CDBL() or ToNumber() should work. Just remember that when it displays, it might only show the first two digits (and it rounds). Look for the increase decimals icon on the toolbar.

I hope this helps.
 
Im pretty sure it is already doing what you want.

create this formula and place it in your report
cdbl("0.07654")
the initial result will look like .08 but if use the menu icon to add decimals you will see that the report format is rounding for display but the actual value is 0.07654. the other way to add decimals if you don't know the icon im talking about is... right click.. format field... number tab... customize and click decimals.

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
by the way this cant be done using Ccur("0.07654") . This will always round to the penny.


_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
kray4660 and CoSpringsGuy - thanks a lot for your response. I tried CDbl on the exchange rate, and despite formatting to 10 decimal spaces, the displayed value was still 0.80000... But the good news is that (as pointed out), the actual calculation is correct in that the exchange rate being used is still the numerical equivalent of the string. Ultimately, as long as the base calculation is correct, the end result (even if slightly rounded) is still accurate.

Thanks a lot for your help!
 
If you increased the number of decimals and you are still seeing 0.80000 then the string value was probably "0.08" rather than "0.07654"
The suggestions above are accurate.

hth,
- Ido

view, export, burst, email, and schedule Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top