• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Fraction Maker Revisited Solved?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fraction Maker Revisited Solved?


  • Subject: Fraction Maker Revisited Solved?
  • From: Jason Bourque <email@hidden>
  • Date: Sat, 06 Nov 2004 21:59:58 -0500

Hello,  a few weeks back I asked for a fraction maker that would round to
get to the nearest recognizable fraction (1/1 to 1/32). So I came up with
this. It does comparisons instead of rounding. I know what type of fraction
I want so I make them and compare the decimal to it. Then run a fraction
flattening loop that brings things like 16/32 to 1/2. I like the result.
Any thoughs on this one? Jason Bourque

You can make it tighter by lowering the bottom number to 16 or 8


set vNumberToFraction to 0.874
set vFractionFound to ""
set vBottomNumber to 32

repeat with vNth from 1 to vBottomNumber

    copy vNth to vTopNumber

    set vDividedNumber to vTopNumber / vBottomNumber

    if vNumberToFraction is less than vDividedNumber then
        repeat -- This brings ups the fraction if possible
            if (vTopNumber mod 2 = 0) and (vBottomNumber mod 2 = 0) then
                set vTopNumber to (vTopNumber / 2) as integer
                set vBottomNumber to (vBottomNumber / 2) as integer
            else
                set vFractionFound to ("" & vTopNumber & "/" &
vBottomNumber) as text
                exit repeat
            end if
        end repeat
        -- Needed to escape from second repeat loop
        if vFractionFound is not "" then exit repeat
    end if
end repeat

return {vNth, vTopNumber, vDividedNumber, vFractionFound}


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Fraction Maker Revisited Solved?
      • From: Jason Bourque <email@hidden>
References: 
 >Re: Bridge anyone? [not off topic] (From: Nigel Garvey <email@hidden>)

  • Prev by Date: Re: Alias Forms as Property (Was: Applescript-users Digest, Vol 1, Issue 177, Message 3)
  • Next by Date: Re: Fraction Maker Revisited Solved?
  • Previous by thread: Re: Bridge anyone? [not off topic]
  • Next by thread: Re: Fraction Maker Revisited Solved?
  • Index(es):
    • Date
    • Thread