Convert decimal value to fraction

ramsay18477
Member Posts: 52
Hi,
I have to compare decimal values from a field with fraction values from another field. Basically, the values in both fields are same i.e, a '6.75' value in the decimal field is '6 3/4' in the code field which I want to compare to trigger another set of codes if they match. For this, I have to convert the decimal value to fraction. Is there a way to do this ?
I searched quite a bit to find a related topic but couldn't seem to find any.
Thanks a lot for your help.
I have to compare decimal values from a field with fraction values from another field. Basically, the values in both fields are same i.e, a '6.75' value in the decimal field is '6 3/4' in the code field which I want to compare to trigger another set of codes if they match. For this, I have to convert the decimal value to fraction. Is there a way to do this ?
I searched quite a bit to find a related topic but couldn't seem to find any.
Thanks a lot for your help.
Thanks & Best Regards,
Ram.
Ram.
0
Comments
-
change the fraction to decimal instead0
-
..but the other way is more fun for a developer :-)
As examples, the fraction .75 can be expressed as 75/100 or .abcd can be expressed as abcd/10000, etc.
Then it's just a matter of reducing the fraction to the smalles whole denominator. I would assume that the easiest is to keep on dividing with the smallest prime number (2) until you cannot do that anymore, then go to the next (3) and do the same, etc.
So for example:
75/100 = 15/20 (divide by 5, as neither 2 or 3 can be used)
=3/4 (second iteration with 5). And since (5>3) or (5>4) = true, then you're done.Bardur Knudsen
Microsoft - Dynamics NAV0 -
It's not fun when it's on customer 's time.0
-
ara3n wrote:It's not fun when it's on customer 's time.
Thank you for this, Rashed. Maybe this sentence describes a difference between the POV of a consultant (paid by the customer) and a product developer at Microsoft. Yes, we want to get paid. And yes, this has become increasingly difficult with the newer releases of NAV. But at least IMO, our abilities haven't faltered.
With best regards
Jens0 -
My opologies for an insensitive comment. I just meant that sometimes we as developers welcome uncommon problems.
And yes, I know someone has to pay - I used to work as a consultant and had to bill my time, and no, my customers wouldn't think it was "fun" to pay for new development.Bardur Knudsen
Microsoft - Dynamics NAV0 -
Working with Microsoft has some pro's but this one of the con's.
Don't take it personal and please keep on posting here. I found your solution interesting to read.0 -
mdPartnerNL wrote:Don't take it personal and please keep on posting here. I found your solution interesting to read.0
-
mdPartnerNL wrote:Don't take it personal and please keep on posting here. I found your solution interesting to read.
Also +1. Never mind the frustration, we also do things for fun... and profit.
With best regards
Jens0 -
Thanks a lot everyone.
Rashed, I did as you said last saturday.
I split the fraction into individual integers, converted into decimals and added it to the while number.
But, I guess we can not do in Navision what I had originally asked...
Thanks again.Thanks & Best Regards,
Ram.0 -
BardurKnudsen wrote:I would assume that the easiest is to keep on dividing with the smallest prime number (2) until you cannot do that anymore, then go to the next (3) and do the same, etc.
The Euclidean algorithm provides a nice method of finding the greatest common divisor (GCD) of two positive integers. The GCD of the numerator and denominator of the fraction can be used to reduce the fraction to lowest terms.0 -
The Euclidean algorithm provides a nice method of finding the greatest common divisor (GCD) of two positive integers. The GCD of the numerator and denominator of the fraction can be used to reduce the fraction to lowest terms.
That would be the ideal solution. But it is difficult to implement in Navision in the absence of any readily available function. For eg. at the first step itself, we have to separate the whole number and the decimal parts, then find the number of decimals and divide by 100, 1000 or so on accordingly. The next challenge is to make the system recognize and divide the numerator and denominator only by prime numbers starting with the least until you reach a point where you cannot divide any further.
Such a function, if attempted, would take time to develop but I think would definitely be worthwhile.
Maybe Microsoft can consider for future versions.Thanks & Best Regards,
Ram.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
- 320 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