× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Are you already doing this in RPG and want to move to SQL? or is this new stuff?

I believe the first step is to decide granularity; is there a desire to get finer than n/32's?
In that case you could adjust/round the decimal to a multiple of .03125
(For instance, where your decimal is .nnnnn: .nnnnnn /.03125 = x, an integer.) Your fraction will be x/32.
Lowering the answer to its lowest common denominator is a loop of:
While remainder of x/2 = 0, divide top & bottom by 2.

On 12/21/2016 11:00 AM, Gerald Magnuson wrote:
I am looking for a sql function that would turn a decimal number to a
fraction.

I found the following, for ORACLE... and tried to make it work for DB2 for
i...
but I am not nearly capable for that...
https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:410098200346123548


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.