13 Replies Latest reply on Feb 17, 2009 12:21 AM by FentonJones

# How can I Convert Decimals to Fractions

### Title

How can I Convert Decimals to Fractions

### Post

I've been racking my brain trying to write a calculation that returns a fraction from a decimal. I've seen the calculations which convert decimals to fractions, but not the other way around. I'm creating a photo library and when I import the metadata from the image it displays as a decimal. Unfortunately, I don't relate 0.00625 as being 1/160 of a second. It's not a quick read. I also need the formula to calculate longer exposures, it would be fabulous if the same calculation field could correctly display 1 min 32 sec. or 15 sec. or 1/5000 sec. depending on what the actual shutter speed was. The imported number is formatted as .00625 which I have been able to convert into a time format as 0:00:00.159999 using the calculation .001 / Exposure Time

Any one up for the challenge? Your help would be greatly appreciated!

• ###### 1. Re: How can I Convert Decimals to Fractions

Welcome to the forum, TasunkeWitko,

I bet the answer is in here:

http://www.fmforums.com/forum/showtopic.php?tid/192065/

HTH,

Alan.

• ###### 2. Re: How can I Convert Decimals to Fractions

Try:

Case ( Exposure Time < 1 ; "1/" & Round ( 1 / Exposure Time ; 0 ) ; Exposure Time )

The result type is Text.

Note that this works with standard shutter speeds - not all fractions in general.

• ###### 3. Re: How can I Convert Decimals to Fractions

Comment, Thank you for the quick reply! The formula works great! I'll test it with longer exposures (greater than 1 sec.) If I manually enter 3 seconds it returns 3 and 90 seconds as 90, so far so good. As a commercial photographer I routinely shoot at much longer exposures. It's great to have the shutter speed displayed correctly. Thanks again!

• ###### 4. Re: How can I Convert Decimals to Fractions

Sorry, I missed that part. Try something like:

Let ( [
min = Div ( Exposure Time ; 60 ) ;
sec = Mod ( Exposure Time ; 60 )
] ;
Case ( min ; min & " min " )
&
Case ( sec ≥ 1 or not sec ; sec ; "1/" & Round ( 1 / sec ; 0 ) ) & " sec"
)

• ###### 5. Re: How can I Convert Decimals to Fractions
I gave that a try, but it said the specified field could not be found. Thinking that I needed a min and sec fields, I added them. Didn't make a difference. There's no indication as to which "specified field could not be found", so I'm not certain what to do on that one.
• ###### 6. Re: How can I Convert Decimals to Fractions
It works here. The only field you need is Exposure Time. Which version are you using?
• ###### 7. Re: How can I Convert Decimals to Fractions
Hmm... I'm trying out 10 right now. Might be something up with the trial version. I'm also having trouble importing tiffs and jpegs from a camera. Occasionally I get a dialog that says the image can't be displayed. I check the referenced file and it's 0kb, so FM isn't saving the file correctly/at all. The same image loads correctly if imported from a folder, but there's no metadata attached. I tried the same calculation in FM 6 but "Let" isn't legal there I guess. :(
• ###### 8. Re: How can I Convert Decimals to Fractions

TasunkeWitko wrote:
I tried the same calculation in FM 6 but "Let" isn't legal there I guess. :(

That is correct. It should work in any version from 7 and up - trial or not.

• ###### 9. Re: How can I Convert Decimals to Fractions
We'll try it out again tomorrow after FM10 has had a rest, or maybe it's me that's tired. :)
• ###### 10. Re: How can I Convert Decimals to Fractions

Custom Function here at http://www.briandunning.com/cf/55

Decimal to Fracton

• ###### 11. Re: How can I Convert Decimals to Fractions
Thanks for the link Alan, I found a couple of interesting ones that work well with receipes and woodworking, but so far nothing that works well with shutter speeds, with the exception of the one that comment gave me that works extremely well with shutter speeds shorter than one second and is pretty good with seconds. What I'd really like is one that displays shutter speeds correctly that are longer than one minute, which we do when we're shooting in low light situations and at night. I'd really not have to pull out the calculator to figure out that 1920 seconds is 32 minutes. :)
Thanks for the "Welcome" it's appreciated!
• ###### 12. Re: How can I Convert Decimals to Fractions
Robert, thanks for that, the calculation works real well for the simple fractions, however .00625 returns as 0/64 instead of the correct 1/160. The actual data from the camera is about ten or 12 digits deep, so it's extremely accurate. Not sure how 1/8000th os a second would display :)
• ###### 13. Re: How can I Convert Decimals to Fractions

Try this fraction custom function (actually 3 which work together), at:

Mikhail Edoshin