Rounding-off automatically in decimal field
Aravindh_Navision
Member Posts: 258
Hi Friends,
I have 3 decimal fields in report.
Say A, B and C where C = A + B.
I am multiplying A, B and C with 1.235025 (ERV = exchange rate value) and the results are store in D,E and F respectively.
Then my answer should be: D = E + F. The problem I'm facing here is all these D, E, F fields are automatically rounding off. But I don't want those field to round-off. Instead I should get the exact value with 2 decimal places. How to proceed with it?
The code I wrote is as follows:
I have 3 decimal fields in report.
Say A, B and C where C = A + B.
For example: A = 50310.06; B = 3521.70; C = 53831.76
I am multiplying A, B and C with 1.235025 (ERV = exchange rate value) and the results are store in D,E and F respectively.
Then my answer should be: D = E + F. The problem I'm facing here is all these D, E, F fields are automatically rounding off. But I don't want those field to round-off. Instead I should get the exact value with 2 decimal places. How to proceed with it?
The code I wrote is as follows:
ERV := 1.235025; D := ROUND((A * ERV),0.01,'<'); E := ROUND((B * ERV),0.01,'<'); F := ROUND((C * ERV),0.01,'<');
I'm getting the output as: D := 62134.19 [50310.06 * 1.235025] E := 4349.38 [3521.70 * 1.235025] F := 66483.59. [53831.76 * 1.235025]. The right answer should be: D := 62134.18 E := 4349.38 F := 66483.56
0
Comments
-
Hi Aravindh,
First some clarifications:
ERV = 1.238237 or 1.235025?
D = E + F or F = D + E?0 -
Next: this is what I am getting:
Microsoft Dynamics NAV Classic
D = 62.134,18
E = 4.349,38
F = 66.483,56
OK
So what's the problem?
BTW: this is the code I have created ina codeunit:A := 50310.06; B := 3521.7; //C := 53831.76; C := A + B; ERV := 1.235025; D := ROUND((A * ERV),0.01,'<'); E := ROUND((B * ERV),0.01,'<'); F := ROUND((C * ERV),0.01,'<'); MESSAGE('D = %1\E = %2\F = %3',D,E,F)with all variables of data type Decimal0 -
Thanks lvanvugt for your reply. Below are my answers...
1. ERV := 1.235025;
2. F = D + E0 -
I am getting few differences in output when compared to the actual calculation. Difference of .03 is showing in this case.0
-
What does your code look like?0
-
You must not expect F = F' with
F = D + E and
F' = ROUND(C * ERV)
Are you sure, the values you gave us are the actual values or might this be the true values rounded for display?0 -
Thanks vaprog,
The examples that I have given here are the real ones. This I am doing for Invoice. If even .02 difference occurs, it will be questioned in auditing.0 -
Are all these A,B,C,D,E,F,ERV variables or fields from a table? This may happen if the "DecimalPlaces" property of the decimal fields is set with some value, say 2:2, or for that matter anything else.
Check this option also if the calculation in question is getting the values from table fields..
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

