This is a public Forum  publicRSS

Forum post

    TasunkeWitko
    How can I Convert Decimals to FractionsAnswered
    Forum post posted February 15, 2009 by TasunkeWitko, last edited February 9, 2012
    737 Views, 13 Comments
    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!

    Best Answer

    TasunkeWitko
    posted February 15, 2009 by TasunkeWitko  Permalink

    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! :smileyhappy:

    Answer

    • Sorbsbuster
      posted February 15, 2009 by Sorbsbuster  Permalink

      Welcome to the forum, TasunkeWitko,

       

      I bet the answer is in here:

       

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

       

      HTH,

      Alan.

    • comment
      posted February 15, 2009 by comment  Permalink

      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.

    • TasunkeWitko
      posted February 15, 2009 by TasunkeWitko  Permalink

      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! :smileyhappy:

    • comment
      posted February 15, 2009 by comment  Permalink

      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"
      )

    • TasunkeWitko
      posted February 15, 2009 by TasunkeWitko  Permalink
      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.
    • comment
      posted February 15, 2009 by comment  Permalink
      It works here. The only field you need is Exposure Time. Which version are you using?
    • TasunkeWitko
      posted February 15, 2009 by TasunkeWitko  Permalink
      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. :(
    • comment
      posted February 15, 2009 by comment  Permalink

      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.

    • TasunkeWitko
      posted February 15, 2009 by TasunkeWitko  Permalink
      We'll try it out again tomorrow after FM10 has had a rest, or maybe it's me that's tired. :)
    • RSchaub
      posted February 15, 2009 by RSchaub  Permalink

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

      Decimal to Fracton