Results 1 to 5 of 5

Thread: Ratio Formula

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    33

    Ratio Formula

    Hello, i've done a search and found this topic:

    http://www.vbforums.com/showthread.p...=ratio+numbers

    I'm trying to find and most importantly understand a formula for calculating the ratio between 2 numbers.

    The example in the thread above gives me the answers, but im confused about what its doing. The strangest being this:

    If (val_1 / min_val) = (val_1 \ min_val) And (val_2 / min_val) = (val_2 \ min_val) Then

    What is the difference between the forward facing '/' and the backwards facing '\' as they sometimes give different results. Maybe if i understood what they were doing i could get the rest.

    In my opinion, val_1 Divided by min_val will always equal val_1 Divided by min_val.

    By the way, my code is actually in Java, but i'm reasonably happy converting it to java myself.

    Thanks for any help!

    Mathew

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Ratio Formula

    / is standard division which returns a double
    \ is integer division and only returns the integer part of a division result.

    e.g.
    2 / 3 = 0.666666666...
    2 \ 3 = 0

    a comparison like (val_1 / min_val) = (val_1 \ min_val) is checking to see if the result of the division is an integer.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    33

    Re: Ratio Formula

    thanks bushmobile!! Thats cleared things up a lot. I'll post again if i get confused anymore.

    Quick reply too, nice one!

    Mathew

  4. #4
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Ratio Formula

    More examples:
    Int(2/3) = 2\3 = 0
    Int(3/2) = 3\2 = 1
    4\2 = 4/2 = 2

    You can thus use this feature for a nice comparison:

    If N/2 = N\2 Then ' you know that N is evenly divisible by 2 and thus an even number. Otherwise, it's odd.
    Doctor Ed

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    33

    Re: Ratio Formula

    Quote Originally Posted by MathewF
    By the way, my code is actually in Java, but i'm reasonably happy converting it to java myself.
    Seems i'm having quite a few problems and i go back on my word now. Just wondered if anyone could help me convert this code to java? I've started a new thread about this over in the java forums:

    http://www.vbforums.com/showthread.p...77#post2804677

    Thanks a bunch!

    Mathew

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width