Fractions rounded to 1/4, 1/8, 1/16, 1/32, 1/64, 1/128

Location: http://www.mvps.org/dmcritchie/excel/fractex1.htm      
Home page: http://www.mvps.org/dmcritchie/excel/excel.htm
[View without Frames]

The formatted display of fractional measurements in Excel leaves a lot to be desired.  This example and the formulas shown below were generously provided by Bernie Deitrick as a followup to a posting 2000-08-04 in the microsoft.public.excel.misc newsgroup.

These do, of course, require a cell on the worksheet for the value and another for the text formatting.

 
 ABCDE
1 26.0827 Fr: Simple Decimal
To: Simple Fractions
Fr: Decimal Inches
To: Fractional Inches
Fr: Decimal Feet
To: Feet and Fractional Inches
Fr: Decimal Inches
To: Feet and Fractional Inches
2Down to 4ths 2626" 26' 1"2' 2"
3Down to 8ths 26 1/826 1/8" 26' 1"2' 2 1/8"
4Down to 16ths 26 1/1626 1/16" 26' 1"2' 2 1/16"
5Down to 32nds 26 3/3226 3/32" 26' 1"2' 2 3/32"
6Down to 64ths 26 5/6426 5/64" 26' 0 63/64"2' 2 5/64"
7Down to 128ths 26 11/12826 11/128" 26' 0 127/128"2' 2 11/128"
8      
9 This spreadsheet gives formulas used to display decimal values given in cell A1 as fractions with the denominator being variable and chosen as the smallest among 2,4,8,16.... as appropriate.
Equations developed by Bernie Deitrick mailto:deitbe@consumer.org

 
b1 Fr: Simple Decimal To: Simple Fractions
b226 =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/8," 0/"&CHOOSE(ROUND(MOD(A1,1)*4,0),4,2,4),""))
b326 1/8 =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/16," 0/"&CHOOSE(ROUND(MOD(A1,1)*8,0),8,4,8,2,8,4,8),""))
b426 1/16 =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/32," 0/"&CHOOSE(ROUND(MOD(A1,1)*16,0),16,8,16,4,16,8,16,2,16,8,16,4,16,8,16),""))
b526 3/32 =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32},0)-A1*{2,4,8,16,32})/{2,4,8,16,32}),ABS(ROUND(A1*{2,4,8,16,32},0)-A1*{2,4,8,16,32})/{2,4,8,16,32},0),2,4,8,16,32),""))
b626 5/64 =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32,64)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32,64},0)-A1*{2,4,8,16,32,64})/{2,4,8,16,32,64}),ABS(ROUND(A1*{2,4,8,16,32,64},0)-A1*{2,4,8,16,32,64})/{2,4,8,16,32,64},0),2,4,8,16,32,64),""))
b726 11/128 =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32,64,128)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32,64,128},0)-A1*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128}),ABS(ROUND(A1*{2,4,8,16,32,64,128},0)-A1*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128},0),2,4,8,16,32,64,128),""))
   
c1 Fr: Decimal Inches To: Fractional Inches
c226" =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/8," 0/"&CHOOSE(ROUND(MOD(A1,1)*4,0),4,2,4),""))&""""
c326 1/8" =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/16," 0/"&CHOOSE(ROUND(MOD(A1,1)*8,0),8,4,8,2,8,4,8),""))&""""
c426 1/16" =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/32," 0/"&CHOOSE(ROUND(MOD(A1,1)*16,0),16,8,16,4,16,8,16,2,16,8,16,4,16,8,16),""))&""""
c526 3/32" =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32},0)-A1*{2,4,8,16,32})/{2,4,8,16,32}),ABS(ROUND(A1*{2,4,8,16,32},0)-A1*{2,4,8,16,32})/{2,4,8,16,32},0),2,4,8,16,32),""))&""""
c626 5/64" =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32,64)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32,64},0)-A1*{2,4,8,16,32,64})/{2,4,8,16,32,64}),ABS(ROUND(A1*{2,4,8,16,32,64},0)-A1*{2,4,8,16,32,64})/{2,4,8,16,32,64},0),2,4,8,16,32,64),""))&""""
c726 11/128" =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32,64,128)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32,64,128},0)-A1*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128}),ABS(ROUND(A1*{2,4,8,16,32,64,128},0)-A1*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128},0),2,4,8,16,32,64,128),""))&""""
   
d1 Fr: Decimal Feet To: Feet and Fractional Inches
d226' 1" =IF(A1>=1,INT(A1)&"' ","")&TEXT(MOD(A1,1)*12,"0"&IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/8," 0/"&CHOOSE(ROUND(MOD(MOD(A1,1)*12,1)*4,0),4,2,4),""))&""""
d326' 1" =IF(A1>=1,INT(A1)&"' ","") & TEXT(MOD(A1,1)*12,"0"&IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/16," 0/"&CHOOSE(ROUND(MOD(MOD(A1,1)*12,1)*8,0),8,4,8,2,8,4,8),"")) &""""
d426' 1" =IF(A1>=1,INT(A1)&"' ","") & TEXT(MOD(A1,1)*12,"0"&IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/32," 0/"&CHOOSE(ROUND(MOD(MOD(A1,1)*12,1)*16,0),16,8,16,4,16,8,16,2,16,8,16,4,16,8,16),"")) &""""
d526' 1" =IF(A1>=1,INT(A1)&"' ","") & TEXT(MOD(A1,1)*12,"0" &IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/MAX(2,4,8,16,32)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32},0)-MOD(A1,1)*12*{2,4,8,16,32})/{2,4,8,16,32}),ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32},0)-MOD(A1,1)*12*{2,4,8,16,32})/{2,4,8,16,32},0),2,4,8,16,32),""))&""""
d626' 0 63/64" =IF(A1>=1,INT(A1)&"' ","") & TEXT(MOD(A1,1)*12,"0" &IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/MAX(2,4,8,16,32,64)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32,64},0)-MOD(A1,1)*12*{2,4,8,16,32,64})/{2,4,8,16,32,64}),ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32,64},0)-MOD(A1,1)*12*{2,4,8,16,32,64})/{2,4,8,16,32,64},0),2,4,8,16,32,64),""))&""""
d726' 0 127/128" =IF(A1>=1,INT(A1)&"' ","") & TEXT(MOD(A1,1)*12,"0" &IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/MAX(2,4,8,16,32,64,128)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32,64,128},0)-MOD(A1,1)*12*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128}),ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32,64,128},0)-MOD(A1,1)*12*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128},0),2,4,8,16,32,64,128),"")) & """"
   
e1 Fr: Decimal Inches To: Feet and Fractional Inches
e22' 2" =INT(A1/12)&"' " &TEXT(MOD(A1,12),"0"&IF(ABS(MOD(A1,12)-ROUND(MOD(A1,12),0))>1/8," 0/"&CHOOSE(ROUND(MOD(MOD(A1,12),1)*4,0),4,2,4),""))&""""
e32' 2 1/8" =INT(A1/12)&"' " & TEXT(MOD(A1,12),"0"&IF(ABS(MOD(A1,12)-ROUND(MOD(A1,12),0))>1/16," 0/"&CHOOSE(ROUND(MOD(MOD(A1,12),1)*8,0),8,4,8,2,8,4,8),"")) & """"
e42' 2 1/16" =INT(A1/12)&"' " & TEXT(MOD(A1,12),"0"&IF(ABS(MOD(A1,12)-ROUND(MOD(A1,12),0))>1/32," 0/"&CHOOSE(ROUND(MOD(MOD(A1,12),1)*16,0),16,8,16,4,16,8,16,2,16,8,16,4,16,8,16),"")) & """"
e52' 2 3/32" =INT(A1/12)&"' " & TEXT(MOD(MOD(A1,12),12),"0"&IF(ABS(MOD(MOD(A1,12),12)-ROUND(MOD(MOD(A1,12),12),0))>1/64," 0/"&CHOOSE(ROUND(IF(MOD(MOD(MOD(A1,12),12),1)-0.5>0,MOD(MOD(MOD(A1,12),12),1)-0.5,MOD(MOD(MOD(A1,12),12),1))*32,0)+1,2,32,16,32,8,32,16,32,4,32,16,32,8,32,16,32,2),""))& """"
e62' 2 5/64" =INT(A1/12)&"' " &TEXT(MOD(A1,12),"0" &IF(ABS(MOD(A1,12)-ROUND(MOD(A1,12),0))>1/MAX(2,4,8,16,32,64)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(MOD(A1,12)*{2,4,8,16,32,64},0)-MOD(A1,12)*{2,4,8,16,32,64})/{2,4,8,16,32,64}),ABS(ROUND(MOD(A1,12)*{2,4,8,16,32,64},0)-MOD(A1,12)*{2,4,8,16,32,64})/{2,4,8,16,32,64},0),2,4,8,16,32,64),""))&""""
e72' 2 11/128" =INT(A1/12)&"' " & TEXT(MOD(A1,12),"0" &IF(ABS(MOD(A1,12)-ROUND(MOD(A1,12),0))>1/MAX(2,4,8,16,32,64,128)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(MOD(A1,12)*{2,4,8,16,32,64,128},0)-MOD(A1,12)*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128}),ABS(ROUND(MOD(A1,12)*{2,4,8,16,32,64,128},0)-MOD(A1,12)*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128},0),2,4,8,16,32,64,128),""))&""""

 


Presentation above Copyright ©2000, Bernie Deitrich

Preparation of Data on this Page

A second sheet was copied from the original Excel spreadsheet supplied by Bernie and the formulas used were displayed as follows:

A12:  B2
B12:  (pasted from B2)
C12:  =GetFormula(indirect(A12))

The original section was converted to HTML with XL2HTMLX, and the formulas section was converted to HTML with XL2HTML with macros described on my HTML page.

Related


You are one of many distinguished visitors who have visited my site here or in a previous location  since this page was created on August 08, 2000.

Visit [my Excel home page]   [Index page]   [Excel Onsite Search]   [top of this page]

Presentation in HTML format by David McRitchie mailto:DMcRitchie@msn.com.

Appreciative comments should be directed to Bernie Deitrick mailto:deitbe@consumer.org for the content.