# Converting a decimal into a fraction measurement?

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

## Recommended Posts

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?

##### Share on other sites

See if this helps.

##### Share on other sites

Awesome! I was about 75% to the same type of calculation myself :.

##### Share on other sites

comment your resourceful..ness in terms of links will never seem to amaze me :

##### Share on other sites

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

##### Share on other sites

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?

##### Share on other sites

Huh? 0.75 returns "3/4", unless we're not talking about the same formula.

##### Share on other sites

No I was saying after my changes it didn't. But yours if you do .5 returns 2/4.

##### Share on other sites

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 )

)

• 1

Thanks!

##### Share on other sites

• 1 month later...
• Newbies

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.

##### Share on other sites

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

##### Share on other sites

• Newbies

Thanks for the advise, it was of great value.

##### Share on other sites

This topic is 5703 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