|
-
Mar 7th, 2007, 10:57 AM
#1
Thread Starter
Member
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
-
Mar 7th, 2007, 11:02 AM
#2
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.
-
Mar 7th, 2007, 11:05 AM
#3
Thread Starter
Member
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
-
Mar 7th, 2007, 12:24 PM
#4
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.
-
Mar 7th, 2007, 12:42 PM
#5
Thread Starter
Member
Re: Ratio Formula
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|