Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Converting a decimal into a fraction measurement?


This topic is 6864 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have found a sub routine that will convert a decimal to a fraction with a set degree of accuracy. But I need something that will only work in 1/2, 1/4, 1/8, 1/16 (powers of 2).

Anyone know of anything to help me?

Posted

in terms of links will never seem to amaze me

LOL - No he's definately under avarage in that dept. : - but when it comes to cleverness, he never SEIZE to amaze me, at least!

--sd

Posted

I can't figure out how to add in 1/2 conversions? I got it to do .5 to 1/2, but then when I had .75 it would do 1.5/2.

Think you could modify that for me?

Posted

I see. Well, that was the requirement then.

Here's a more general formula, adapted from Mikhail Edoshin's "Common fractions from their decimal representation". You can adjust the precision parameter (in powers of two) to the smallest division you want to be shown.

Let ( [

precision = 16 ;

num = Round ( Number * precision ; 0 ) / precision ;

fraction = Mod ( num ; 1 ) ;

len = Length ( fraction ) ;

denom = Case ( len ; 2^( len - 1 ) )

] ;

Case ( Int ( num ) or not fraction ; Int ( num) )

&

Case ( Int ( num ) and fraction ; " " )

&

Case ( fraction ; fraction * denom & "/" & denom )

)

  • Like 1
  • 1 month later...
  • Newbies
Posted

I am a novice with filemaker. I have two fields in which i want to enter a width and height in a fraction ( as 30-1/4") in the next field to calculate the result of total square footage in want the result to be in a whole number, but it does not add up correctly. I have been trying different things with no luck, any insight would be greatly appreciated.

Posted

If I'm understanding you correctly, you want to take a number such as 11 1/5 and have it enter as 11.5 in the field?

If so, go to this URL:

http://www.databasepros.com/resources.html

and do a find for Fraction

and it will return two files. check them both out.

Lee

This topic is 6864 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.