Dynamic Fraction Display For ColdFusion

You may also like...

2 Responses

  1. This worked great – thanks for posting it. I had to make 2 small mods for my project. It allow for 1/16ths precision and better display (a space character was in the wrong place). Here they are:

    To allow for 16th of an inch, change line to 5 to:
    [cfset fractionPart = (numberFormat(formatThis,”.9999″) – int(formatThis)) * 100]
    (setting precision to 4 places)

    Then for better display, change line 18 to:
    [cfset fraction = “#wholePart# “]
    (adding a space)
    … and line 24 to:
    [cfset fraction = fraction & “#numerator#/#denominator#”]
    (removing a space)

  2. Greg Nilsen says:

    Glad you found this useful! Since I was using it for a recipe application, I had not really tested anything more precise than 18th, since most recipes don’t call for anything smaller than that. Thanks for posting your tweaks as well!

Leave a Reply