Anyone wanna help me work out some math?
Posted: Thu Jul 26, 2012 7:52 am
Okay so I'm going to be looping through some number between 0 and 1, adding it over and over until it becomes some whole number.
Probably won't be anything too complicated in reality - something that will work itself out on the first pass of 1 or 2 - but I don't want it to break years down the road when I forget the implementation is a corner cutter, right? I might end up using really obscure fractions like 999/1000 to simulate more natural patterns of what I'm working on, which should have a noticeable impact.
Now the two concerns I have is that I'm working with fractions implicitly, but floats explicitly. Those two don't agree much when you're checking if x == 1.
Again, what I'm trying to do is calculate ahead of time how many steps I would need to hit a nice, whole number.
I'm thinking I should use factorization into primes, eliminate any prime subsets in common, and roll with some kind of least common denominator or whatever it's called? But how would I do this with floats that might have decimals? I guess since I'm working with floats I should just convert everything to a float but it's more of an analog thing than a digital thing so I'm kind of not wanting to go too far into the bits world without at least some really high degree of accuracy approximation.
My algorithm for generating the floats is going to look like this:
step = (Maximum / (Number * Multiplier))
Number should be like 500 but can be 500.01 and I need that to be pretty accurate. At most 15000, at least 20.
Multiplier should be like 6.0 but could again be 6.01 and I need that to be pretty accurate as well. At most 1000, at least .001.
Maximum will always be some large number like 50000, but might be something like 50024.
Probably won't be anything too complicated in reality - something that will work itself out on the first pass of 1 or 2 - but I don't want it to break years down the road when I forget the implementation is a corner cutter, right? I might end up using really obscure fractions like 999/1000 to simulate more natural patterns of what I'm working on, which should have a noticeable impact.
Now the two concerns I have is that I'm working with fractions implicitly, but floats explicitly. Those two don't agree much when you're checking if x == 1.
Again, what I'm trying to do is calculate ahead of time how many steps I would need to hit a nice, whole number.
I'm thinking I should use factorization into primes, eliminate any prime subsets in common, and roll with some kind of least common denominator or whatever it's called? But how would I do this with floats that might have decimals? I guess since I'm working with floats I should just convert everything to a float but it's more of an analog thing than a digital thing so I'm kind of not wanting to go too far into the bits world without at least some really high degree of accuracy approximation.
My algorithm for generating the floats is going to look like this:
step = (Maximum / (Number * Multiplier))
Number should be like 500 but can be 500.01 and I need that to be pretty accurate. At most 15000, at least 20.
Multiplier should be like 6.0 but could again be 6.01 and I need that to be pretty accurate as well. At most 1000, at least .001.
Maximum will always be some large number like 50000, but might be something like 50024.