my c
my c
Last edited by lyojarhhs; 10-15-2006 at 12:10 PM.
hmmm... maybe more info? like what type do you use for all those variable ? (int, double, float etc)
Code:#include <stdio.h> #include <math.h> main () { int size, level, temp, max_population, max_pop_generations, population, hours, k, k_size, k_temp, l_level, e, k_rate_of_change, generations ; max_population = 0 ; max_pop_generations = 0 ; generations = 0 ; population = 1 ; hours = generations * 20 / 60 ; e = M_E ;
that int is your problem...
use float...
try this
Code:#include <stdio.h> int main() { int a = 10.0 / 3; printf("%d\n", a); float b = 10.0 / 3; printf("%f\n", b); return 0; }
Last edited by yxunomei; 10-14-2006 at 08:35 PM.
Do note that ^ is not exponents. (It's a binary xor.) For exponents, lookup the function pow.Code:population = 1 * ( M_E ^ (( 1 - k ) * generations )) ;
And to further explain, integers, the type you were using, cannot hold numbers like M_E. (e is not an integer - it's rational.) To hold numbers like .25, pi, e, etc, use float or double. (double gives more precision.)
Last edited by Cactus_Hugger; 10-14-2006 at 10:59 PM.
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)