Post Reply 
Decimal fraction to architectural fraction
02-25-2016, 12:06 PM (This post was last modified: 02-26-2016 01:30 PM by DrD.)
Post: #1
Decimal fraction to architectural fraction
No expert here, but there must have been hundreds of times when I have wanted a quick conversion from a decimal fraction to an architectural fraction (quarters, eighths, sixteenths, etc.). There are probably much better ways to do this, but here is a handy approach (I hope) returns the nearest architectural fraction (greater than or equal to) the provided decimal number. I solicit improvements! (Better filename, better method, etc.).

A built-in command for something like this sure would be nice.

Code:

//                  A2(N,A)
//                 02/24/2016  
//  Decimal fraction to Architectural fraction >= provided decimal number.
//    INPUT:    A2(Decimal number, desired architectural denominator)
//    Example:  A2(3.53553390593,16) ==>  "3 9/16"

EXPORT f2a(N,A)
BEGIN
  return STRING(IP(N)) + " " + STRING(CEILING(ROUND(FP(N)*A,5))) + "/" + STRING(A);
END;

-Dale-
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Decimal fraction to architectural fraction - DrD - 02-25-2016 12:06 PM



User(s) browsing this thread: 1 Guest(s)