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 follow-up to a posting 2000-08-04 in the microsoft.public.excel.misc newsgroup.  Bernie's formulas will be simplified after comments from Harlan Grove and corrections from by Ron Rosenberg on 2003-01-03

The corrections to be made will allow the numbers to be treated arithmetically, though they are being formatted strictly for display.  The other formulas showing mixed feet, inches and fractional inches will still requidre something more than these simplified formulas, and will be text to allow feet and inch marks to appear next to figures even if strictly Feet and fractional feet.

 


I believe the formula on this page will need some revision based on the following advice by Ron Rosenberg on 2003-01-26
Disadvantage of  # #/##  formatting,
  A1:  26
  B2:  =MROUND(A1,1/32)    formatted   as   # #/##  -- MROUND is in Analysis Tookpak
displays in B2  as    26 0/1  as would the non Analysis Toolpak Function version 
  B2:  =ROUND(A1*32,0)/32     formatted  as   # #/##  

---------------- Examples for 1/4, 1/8, 1/16, 1/32, 1/64 -----------
for 4ths
=ROUND(A1*4,0)/4        -- format as 0 #/##

for 8ths
=ROUND(A1*8,0)/8        -- format as 0 #/##

for 16ths
=ROUND(A1*16,0)/16     -- format as 0 #/##

for 32nds
=ROUND(A1*32,0)/32     -- format as 0 #/##

for 64ths
=ROUND(A1*64,0)/64     -- format as 0 #/##


Simplified Formulas:  Bernie Deitrick sent (2005-03-04) sent me a simplied means of redoing his previous work -- see how long it takes me to actually change formulas used.  For Feet and fractional inches.

formula for cell E7:
=INT(A1/12)&"'  "&INT(MOD(A1,12))&""&IF(INT(A1)<>A1," " & TEXT(ROUND((A1-INT(A1/12)*12-INT(MOD(A1,12)))*128,0)/128,"##/###"),"")&""""

instead of his previous original beautiful formulas that is shown here to show some neat worksheet functions usage from his Aug 2000 examples: =INT(A1/12)&"' " & TEXT(MOD(A1,12),"0" &IF(ABS(MOD(A1,12)-ROUND(MOD(A1,12),0))>1/256, " 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),""))&""""


 ABCDE
1 26.0827 Fr: Simple Decimal
To: Simple Fractions
Fr: Decimal Inches
To: Fractional Inches
Fr: Decimal Feet
To: Inches and Fractional Inches
Fr: Decimal Inches
To: Feet, Inches and Fract. Inches
2Down to 4ths 2626" 26' 1"2' 2 0/4"
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' 1"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

 

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),""))
=MROUND(A1,1/4)    -- Analysis Toolpak Function -- format as 0 ##/##
=ROUND(A1*4,0)/4    -- Without the Analysis Toolpak Function -- format as 0 ##/##
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),""))
=MROUND(A1,1/8)    -- Analysis Toolpak Function -- format as 0 ##/##
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),""))
=MROUND(A1,1/16)    -- Analysis Toolpak Function -- format as 0 ##/##
b526 3/32 =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/64, " 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),""))
=MROUND(A1,1/32)    -- Analysis Toolpak Function -- format as 0 ##/##
b626 5/64 =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/128, " 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),""))
=MROUND(A1,1/64)    -- Analysis Toolpak Function -- format as 0 ##/##
b726 11/128 =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/256, " 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),""))
=MROUND(A1,1/128)    -- Analysis Toolpak Function -- format as 0 ##/##
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/64, " 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/128, " 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/256, " 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" =INT(A$1)&""&IF(INT(A$1)<>A$1," " & TEXT(ROUND((A$1-INT(A$1))*4,0)/4,"##/###"),"")&""""
d326' 1" =INT(A$1)&""&IF(INT(A$1)<>A$1," " & TEXT(ROUND((A$1-INT(A$1))*8,0)/8,"##/###"),"")&""""
d426' 1" =INT(A$1)&""&IF(INT(A$1)<>A$1," " & TEXT(ROUND((A$1-INT(A$1))*16,0)/16,"##/###"),"")&""""
d526' 1" =INT(A$1)&""&IF(INT(A$1)<>A$1," " & TEXT(ROUND((A$1-INT(A$1))*32,0)/32,"##/###"),"")&""""
d626' 1" =INT(A$1)&""&IF(INT(A$1)<>A$1," " & TEXT(ROUND((A$1-INT(A$1))*64,0)/64,"##/###"),"")&""""
d726' 0 127/128" =INT(A$1)&""&IF(INT(A$1)<>A$1," " & TEXT(ROUND((A$1-INT(A$1))*128,0)/128,"##/###"),"")&""""
   
e1 Fr: Decimal Inches To: Feet and Fractional Inches
e22' 2 0/4" =INT(A1/12)&"'  "&INT(MOD(A1,12))&""&IF(INT(A1)<>A1," " & TEXT(ROUND((A1-INT(A1/12)*12-INT(MOD(A1,12)))*4,0)/4,"##/##"),"")&""""
e32' 2 1/8" =INT(A1/12)&"'  "&INT(MOD(A1,12))&""&IF(INT(A1)<>A1," " & TEXT(ROUND((A1-INT(A1/12)*12-INT(MOD(A1,12)))*8,0)/8,"##/##"),"")&""""
e42' 2 1/16" =INT(A1/12)&"'  "&INT(MOD(A1,12))&""&IF(INT(A1)<>A1," " & TEXT(ROUND((A1-INT(A1/12)*12-INT(MOD(A1,12)))*16,0)/16,"##/##"),"")&""""
e52' 2 3/32" =INT(A1/12)&"'  "&INT(MOD(A1,12))&""&IF(INT(A1)<>A1," " & TEXT(ROUND((A1-INT(A1/12)*12-INT(MOD(A1,12)))*32,0)/32,"##/##"),"")&""""
e62' 2 5/64" =INT(A1/12)&"'  "&INT(MOD(A1,12))&""&IF(INT(A1)<>A1," " & TEXT(ROUND((A1-INT(A1/12)*12-INT(MOD(A1,12)))*64,0)/64,"##/##"),"")&""""
e72' 2 11/128" =INT(A1/12)&"'  "&INT(MOD(A1,12))&""&IF(INT(A1)<>A1," " & TEXT(ROUND((A1-INT(A1/12)*12-INT(MOD(A1,12)))*128,0)/128,"##/###"),"")&""""

 


Presentation above Copyright ©2000, Bernie Deitrick

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

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

Please send your comments concerning formatting of this web page to: David McRitchie send email comments


Copyright © 1997 - 2004,  F. David McRitchie,  All Rights Reserved // portions within tables © Bernie Deitrick