Value After Decimals Places Changes in Field(Decimal)
fortius_cva
Member Posts: 70
Hi
Greetings
I have a Quantity(Decimal) Field in a table. It is showing a value of 128.39284 in the form. But when in zoom the record and look at the values it is showing me value as 128.39284123456.
why is it happening?? because of this reason, i am not able to compare this field with another field which has the same value(12.39284)..
Greetings
I have a Quantity(Decimal) Field in a table. It is showing a value of 128.39284 in the form. But when in zoom the record and look at the values it is showing me value as 128.39284123456.
why is it happening?? because of this reason, i am not able to compare this field with another field which has the same value(12.39284)..
Thank You
********
Friend Ship is just like breeze.. you can't smell it, touch it,hold it.
********
********
Friend Ship is just like breeze.. you can't smell it, touch it,hold it.
********
0
Comments
-
When you want to compare two decimals, you shoudl always round the numbers to a known precision for you compare the values. Ignorring this step will in most cases result in failing comparison due to tiny roundings that happend during the calculations. The numbers migth look the same, but can have a difference on the last digit.
The numbers you see in the form has been rounded for display purposes, but the data behind has not, which is why your comparison fails. Use the AL function ROUND
Sample code (d1 through d4 are decimals)d1 := 123.123456789; d2 := 123.1234567; d3 := ROUND(d1,10000); d4 := ROUND(d2, 10000); if d3 <> d4 then error('Wrong rounding %1 <> %d', d3, d4);_________________
Niels-Henrik Sejthen
Senior Software Developer
Microsoft Dynamics NAV
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions