java - Changing A Decimal to a whole number (NOT Rounding Off) -
so making application can solve problems empirical formulae , need code like: if numbers 2.5, 1, 3 should alter them 2.5*2 = 5, 1*2 = 2, 3*2 = 6 number decimal converted whole number , other numbers adjusted appropriately.
i thought of logic:
for(n = 1; (math.round(simplestrat[0]) * n) != (int)simplestrat[0]; n++)
to increment counter multiply integer want skeptical code @ phase , not think work.
it lot of help if suggest code or improve upon code or give me link post problem unable find regarding type of problem.
any help appreciated. thanks
okay, have have few steps. first, them whole numbers. easiest way find appropriate powerfulness of 10 multiply them leaves them integers. useful check: how test if double integer.
then cast them integers, , start working through them looking mutual prime factors. this'll process similar eratosthenes' sieve (http://en.wikipedia.org/wiki/sieve_of_eratosthenes) partition @ end. each prime, see if 3 numbers split (modulo prime == 0). if do, split , reset primes 2. if don't, next prime.
this should give lowest mutual ratio between numbers. additional multiplier came original stage shaved off mutual primes method.
java
No comments:
Post a Comment