[zog.org] about | stuff | sites | tsuk | search |    
Thu December 5th 2002 You are here: home > some page I haven't put in the locator thingy yet
cf_fraction v. 1.0
© 1999 by Michel Vuijlsteke, Netpoint NV (michel@netpoint.be)

PARAMETERS
number
number to be converted
precision (default: 5)
necessary precision (digits)
denom (default:0>
use fixed denominator?
table (default:No>
results in table?
font (default:Tahoma)>
font to use in table
fontsize (default:2)>
font size in table
show (default:Yes)>
show result?
DOWNLOAD
CF_FRACTION.ZIP
3,480 bytes Winzip format
ALGORITHM
Click here for the
algorithm used. Many
thanks to Dr. Peterson.
Converts numbers with decimals to fractions. Can format the fraction in a table or just in text (see examples below). Returns integer part, numerator and denominator in intpart, num and denom variables.

Required parameter: number to convert.

<cf_fraction number="4.65583">
4 928/1415

Optional parameters: precision, denom, table, font, fontsize, show.

Precision (default:5). Necessary precision in digits:

<cf_fraction number="4.655831" precision="2">
4 21/32 [4.65625]
<cf_fraction number="4.655831" precision="3">
4 61/93 [4.65591397849]
<cf_fraction number="4.655831" precision="4">
4 343/523 [4.65583173996]

BACK TO TOP

Denom (default:0). Overrides precision and gives a result with a fixed denominator.

<cf_fraction number="4.655831" denom="8">
4 5/8 [4.625]
<cf_fraction number="4.655831" denom="32">
4 21/32 [4.65625]
<cf_fraction number="4.655831" denom="25">
4 16/25 [4.64]

BACK TO TOP

Table (default:No). Formats fraction in a table. Requires a 1x1 pixel transparent gif named "0.gif" in an "images" subdirectory (i.e. <img src="images/0.gif"> should resolve to a file).

<cf_fraction number="4.655831" table="Yes" precision="8">
28810
43929

BACK TO TOP

Font (default:"Tahoma,Arial,Geneva,Helvetica") and Fontsize (default:2). Font and font size the interger part in the table should have. The fraction will be one size smaller in the same font.

<cf_fraction number="4.655831" table="Yes" fontsize="5" precision="8">
28810
43929

<cf_fraction number="4.655831" table="Yes" font="Times New Roman,Times,Serif" fontsize="3" precision="8">
28810
43929

BACK TO TOP

Show (default:Yes). Overrides all other display parameters: the actual result will not be shown. You can still get at the results by using the variables intpart (integer part), num (numerator) and denom (denominator).

<cf_fraction number="4.655831" show="No" precision="8">
<cfoutput>#intpart# plus #num# divided by #denom#<cfoutput>
4 plus 28810 divided by 43929

BACK TO TOP