× 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.



One of the problems to resolve is the layout of the fraction. If you ever
need to sort by size, 1/6 appears greater than 1/2. 
 
The easiest way to resolve the problem is to create an alternating array
where the secondary array is a list of the fractions you consider valid. You
probably don't won't a mathematical solution that will provide an answer of
357/ 512, for instance?
 
Then make the primary array be the decimal notations that will be the
breakpoints for your application. Look up greater-than in the primary, and
there's your fraction, in the arrangement you want.
 
 
---------------------------------------------------------
Booth Martin http://www.MartinVT.com
Booth@xxxxxxxxxxxx
---------------------------------------------------------
 
-------Original Message-------
 
From: RPG programming on the AS400 / iSeries
Date: Friday, October 17, 2003 10:31:20 AM
To: RPG programming on the AS400 / iSeries
Subject: Re: Convert Decimal to Fractional Notation
 
Bob,
 
This would be a cool one to write... I don't have one but here's how I
would approach it:
 
1) Determine what the finest level of measurement you want to return,
i.e. 8th, 16th, 32nd, 64th, etc.
 
2) Create a run-time table of the decimal positions. You only need to
do this for the range of > 0 and < 1.
 
3) Strip the decimal value out of your field.
 
4) Determine your rounding rules and round the remainder to the nearest
value found in the run-time table. The position of the array will be
the top half of the fraction, the factor from 1) will be the bottom
half.
 
5) Divide the fraction down to the smallest valid argument ( 4/16 = 1/4,
etc. )
 
HTH,
 
Joel
http://www.rpgnext.com
 
On Fri, 2003-10-17 at 14:59, Bob O. wrote:
> Does anyone have an example of converting a decimal number to it's
> fractional equivalent?
>
> For example: 15.3750 = 15-3/8
>
> The decimal field to convert is a 10/4 field. Any help is appreciated.
> Thanks in advance.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.