static void count_delay(PERF_RT_Private *me, char *tag, PERF_RTdata_delay *dDelay, long n0) { fprintf(me->fRt, "rtPERF: %s[0x%lX]: ", tag, me->dSTS->size_min); if (dDelay->n > 0) { double x = 1e-6 * dDelay->x / dDelay->n; double xx = 1e-12 * dDelay->xx / dDelay->n; xx = my_sqrt(xx - x * x); if (dDelay->n > 1) { fprintf(me->fRt, "%.3g +- %.3g s (%ld samples)\n", x, xx, dDelay->n); } else { fprintf(me->fRt, "%.3g\n", x); } } else { fprintf(me->fRt, "UNABLE TO CALCULATE\n"); } dDelay->n = n0; dDelay->xx = dDelay->x = 0; }
static void tri_test(void) { mesh* m; point pts[3]; ment v[3]; ment e; unsigned i; double A; double l[3]; double s; m = mesh_new(); pts[0] = point_new(-1,0,0); pts[1] = point_new( 1,0,0); pts[2] = point_new( 0,my_sqrt(3),0); for (i = 0; i < 3; ++i) v[i] = ment_new(m, VERTEX, 0); for (i = 0; i < 3; ++i) mesh_set_point(m, v[i], pts[i]); e = ment_new(m, TRIANGLE, v); A = triangle_area(ment_triangle(m, e)); debug("area: %e\n", A); s = 0; for (i = 0; i < 3; ++i) { mesh_down(m, e, EDGE, i, v); l[i] = line_len(verts_line(m, v)); debug("length: %e\n", l[i]); s += l[i] * l[i]; } s /= 3; debug("condition bound: %e\n", A / s); debug("quality: %e\n", ment_quality(m, e)); mesh_free(m); }
int main( void ) { int i = 0; printf("%f %f\n", sqrt( 4 ), my_sqrt( 4, 2 ) ); printf("%.10f %.10f\n", sqrt( 5 ), my_sqrt( 5, 10 ) ); for( ; i < 10; i++ ) { int n = rand()%100; double t = sqrt( n ); double m = my_sqrt( n, 15 ); double m2 = my_sqrt2( n, 15 ); double diff = t -m ; printf("n=%d %.15f %.15f %.15f \n", n, t, m, m2 ); } return 0; }
int prime2(int n){ int i, sqrn; sqrn = my_sqrt(n); for(i=2;i<=sqrn;i++) if(n%i==0) return !TRUE; return TRUE; }
void sqrt_clicked(GtkButton*w, GtkEntry *entry){ first_operand = atof(gtk_entry_get_text(entry)); result = my_sqrt(first_operand); char str[10]; snprintf(str,10,"%f",result); gtk_entry_set_text(entry,str); }
int main(int argc, const char *argv[]) { float a; printf("Input the num to cal root: \n"); scanf("%f",&a); printf("%.0f 的平方根等于: %.2f\n",a,my_sqrt(a)); return 0; }
void simple_3d_trans(_xyz_f_t *ref, _xyz_f_t *in, _xyz_f_t *out) //С·¶Î§ÄÚÕýÈ·¡£ { static s8 pn; static float h_tmp_x,h_tmp_y; h_tmp_x = my_sqrt(my_pow(ref->z) + my_pow(ref->y)); h_tmp_y = my_sqrt(my_pow(ref->z) + my_pow(ref->x)); pn = ref->z < 0? -1 : 1; out->x = ( h_tmp_x *in->x - pn *ref->x *in->z ) ; out->y = ( pn *h_tmp_y *in->y - ref->y *in->z ) ; // out->x = h_tmp_x *in->x - ref->x *in->z; // out->y = ref->z *in->y - ref->y *in->z; out->z = ref->x *in->x + ref->y *in->y + ref->z *in->z ; }
//圆与线段交,交点加入ret中 void circle_cross_line(Point a, Point b, Point o, double r, vector<Point> &ret) { double x0 = o.x, y0 = o.y; double x1 = a.x, y1 = a.y; double x2 = b.x, y2 = b.y; double dx = x2 - x1, dy = y2 - y1; double A = dx * dx + dy * dy; double B = 2 * dx * (x1 - x0) + 2 * dy * (y1 - y0); double C = sqr(x1 - x0) + sqr(y1 - y0) - sqr(r); double delta = B * B - 4 * A * C; if (sig(delta) >= 0) { double t1 = (-B - my_sqrt(delta)) / (2 * A); double t2 = (-B + my_sqrt(delta)) / (2 * A); if (sig(t1 - 1) <= 0 && sig(t1) >= 0) { ret.PB(Point(x1 + t1 * dx, y1 + t1 * dy)); } if (sig(t2 - 1) <= 0 && sig(t2) >= 0) { ret.PB(Point(x1 + t2 * dx, y1 + t2 * dy)); } } }
void gen_primes (ull limit) { ull m, i, sum = 0, crosslimit = my_sqrt(limit); seive = (char *)calloc(limit, sizeof(char)); for (i = 3; i < crosslimit; i+=2) { seive[i+1] = NOT_PRIME; if (seive[i] == PRIME) { for (m = i*i; m < limit; m+=2*i) { seive[m] = NOT_PRIME; } } } return; }
/* relative error < 2e-11 on [-1, 1] */ float my_acos (float x) { float xa, t; xa = my_fabs (x); /* arcsin(x) = pi/2 - 2 * arcsin (sqrt ((1-x) / 2)) * arccos(x) = pi/2 - arcsin(x) * arccos(x) = 2 * arcsin (sqrt ((1-x) / 2)) */ if (xa > 0.5625) { t = 2.0 * asin_core (my_sqrt (0.5 * (1.0 - xa))); } else { t = 1.5707963267948966 - asin_core (xa); } /* arccos (-x) = pi - arccos(x) */ return (x < 0.0) ? (3.1415926535897932 - t) : t; }
int my_is_prime(int nb) { int i; int end; end = my_sqrt(nb); if (nb % 2 == 0) return 0; i = 3; while (i < end) { if (!(nb % i)) return 0; i = i + 2; } return (1); }
int los_province_distance(int a, int b) { int ra, rb, r1, r2; int ca, cb, c1, c2; int d1, d2; a = province(a); b = province(b); ra = region_row(a) - 1; rb = region_row(b) - 1; ca = region_col(a) - 1; cb = region_col(b) - 1; r1 = min(ra, rb); r2 = max(ra, rb); c1 = min(ca, cb); c2 = max(ca, cb); /* no wrap N-S */ d1 = r2 - r1; if (d1 > (r1 + max_map_row) - r2) d1 = (r1 + max_map_row) - r2; d2 = c2 - c1; if (d2 > (c1 + max_map_col) - c2) d2 = (c1 + max_map_col) - c2; #if 1 return d1 + d2; /* since there is no diagonal movement */ #else d1 *= d1; d2 *= d2; return my_sqrt(d1 + d2); #endif }
int main(){ /* double n, result; std::cin >> n; try{ result = my_sqrt(n); std::cout << result << std::endl; } catch(const std::string& msg){ std::cout << msg << std::endl; } std::cout << "program still continues" << std::endl; */ std::vector<int> v(3); try { my_sqrt(2); std::cout << v.at(33) << std::endl; } catch(const std::out_of_range& e) { std::cout << e.what() << std::endl; } catch(const invalid_sqrt_argument& e) { std::cout << e.what() << std::endl; } catch(const std::logic_error& e) { std::cout << e.what() << std::endl; } return 0; }
void __rt_Done(PERF_Private *perf) { /* get real-time private structure */ PERF_RT_Private *me = perf->cip.pRT; /* print summaries if required */ if (me->summary) { /* uptime summary */ if (me->dUptime) { /* get last uptime */ start_stop_uptime(me->dUptime, 0); fprintf(me->fRt, "rtPERF: ARM CPU-load for%s %c%c%c%c component: ", me->needSteadyState ? " steady state of" : "", PERF_FOUR_CHARS(perf->ulID)); if (me->dUptime->success && me->dUptime->start_uptime) { double load = (100. * (me->dUptime->start_uptime - me->dUptime->start_idletime) / me->dUptime->start_uptime); if (me->dUptime->n) { double x = me->dUptime->x / me->dUptime->n; double xx = me->dUptime->xx / me->dUptime->n; xx = my_sqrt(xx - x * x); if (me->debug & 2) { fprintf(me->fRt, ": %.3g +- %.3g%%\n" "(temporal difference is: %.3g)\n", load, xx, x - load); } else { fprintf(me->fRt, ": %.3g +- %.3g%%\n", load, xx); } } else { fprintf(me->fRt, "%.3g%%\n", load); } } else { fprintf(me->fRt, "FAILED TO CALCULATE\n"); } } /* rate summary */ if (me->nDRate) { int i; for (i = 0; i < me->nDRate; i++) { if (me->dRate[i].n >= MIN_FRAMES_FOR_RATE && ((me->debug & 4) || me->dRate[i].tn0 >= MIN_FRAMES_FOR_RATE)) { double x = me->dRate[i].x * 1e-6 / me->dRate[i].n; double s = (me->dRate[i].xx ? (me->dRate[i].x * (double) me->dRate[i].x / me->dRate[i].xx / me->dRate[i].n) : 1); fprintf(me->fRt, "rtPERF: "); print_rate_info(me->fRt, perf->ulID, me->dRate[i].modulesAndFlags, me->dRate[i].size, me->dRate[i].n); if (x > 0) { if (me->dRate[i].an) { double x2 = me->dRate[i].ax / me->dRate[i].an; double xx = me->dRate[i].axx / me->dRate[i].an; xx = my_sqrt(xx - x2 * x2); if (me->debug & 2) { fprintf(me->fRt, ": %.3g +- %.3g fps (s=%.3g)\n" "(temporal difference is: %.3g)\n", 1/x, xx, s, x2-1/x); } else { fprintf(me->fRt, ": %.3g +- %.3g fps (s=%.3g)\n", 1/x, xx, s); } } else { fprintf(me->fRt, ": %.3g fps (s=%.3g)\n", 1/x, s); } } else { fprintf(me->fRt, ": FAILED TO CALCULATE\n"); } } } } /* shot-to-shot summary */ if (me->dSTS) { if (me->dSTS->dABurst2.n > 0) { count_delay(me, "Avg. modified burst shot-to-shot", &me->dSTS->dABurst2, 0); } if (me->dSTS->dABurst.n > 0) { count_delay(me, "Avg. raw burst shot-to-shot", &me->dSTS->dABurst, 0); } if (me->dSTS->dSingle.n > 0) { count_delay(me, "Avg. single shot-to-shot", &me->dSTS->dSingle, -1); } } } }
static float getRadius(int a, int b, int theta) { float s = (float)sin_lookup(DEG_TO_TRIGANGLE(theta))/TRIG_MAX_RATIO; float c = (float)cos_lookup(DEG_TO_TRIGANGLE(theta))/TRIG_MAX_RATIO; return (a * b) / (my_sqrt((a*a)*(s*s)+(b*b)*(c*c))); }
double mod() { return my_sqrt(sqr(x)+sqr(y)); }
bool CMine::CalcSideLights (int segnum, int sidenum, vms_vector& source_center, vms_vector *source_corner, vms_vector& A, double *effect, double fLightScale, bool bIgnoreAngle) { CDSegment *seg = Segments (segnum); // calculate vector between center of source segment and center of child vms_vector B,center; CalcCenter (center,segnum,sidenum); B.x = center.x - source_center.x; B.y = center.y - source_center.y; B.z = center.z - source_center.z; // calculate angle between vectors (use dot product equation) if (!bIgnoreAngle) { double ratio,angle; double A_dot_B = (double)A.x * (double)B.x + (double)A.y * (double)B.y + (double)A.z * (double)B.z; double mag_A = my_sqrt( (double)A.x*(double)A.x +(double)A.y*(double)A.y +(double)A.z*(double)A.z); double mag_B = my_sqrt( (double)B.x*(double)B.x +(double)B.y*(double)B.y +(double)B.z*(double)B.z); if (mag_A == 0 || mag_B == 0) angle = (200.0 * M_PI)/180.0; // force a failure else { ratio = A_dot_B/(mag_A * mag_B); ratio = ((double)((int)(ratio*1000.0))) / 1000.0; if (ratio < -1.0 || ratio > (double)1.0) angle = (199.0 * M_PI)/180.0; // force a failure else angle = acos(ratio); } // if angle is less than 110 degrees // then we found a match if (angle >= (180.0 * M_PI)/180.0) return false; } int i, j; for (j = 0; j < 4; j++) { vms_vector corner; int vertnum = side_vert[sidenum][j]; int h = seg->verts[vertnum]; corner.x = Vertices (h)->x; corner.y = Vertices (h)->y; corner.z = Vertices (h)->z; double length = 20.0 * m_lightRenderDepth; for (i = 0; i < 4; i++) length = min (length, CalcLength (source_corner + i, &corner) / F1_0); length /= 10.0 * m_lightRenderDepth / 6.0; // divide by 1/2 a cubes length so opposite side // light is recuded by 1/4 effect [j] = 32; if (length > 1.0)//if (length < 20.0 * m_lightRenderDepth) // (roughly 4 standard cube lengths) effect [j] /= (length * length); effect [j] *= fLightScale; // else // effect [j] = 0; } // if any of the effects are > 0, then increment the // light for that side return (effect [0] != 0 || effect [1] != 0 || effect [2] != 0 || effect [3] != 0); }
float sqrt_main(void) { return my_sqrt(19.5); }
int main() { /** Testovani souctu */ // test 1 - celych cisel SHOULD_BE_EQUAL_FLOAT(122.0+105.0,sucet(122.0,105.0),"soucet_1"); // test 2 - desetinnych cisel SHOULD_BE_EQUAL_FLOAT(36514.515+3652.525, sucet(36514.515,3652.525),"soucet_2"); // test 3 - desetinnych cisel s vetsi presnosti SHOULD_BE_EQUAL_FLOAT(9.8+3.1, sucet(9.8,3.1),"soucet_3"); // test 4 - zapornych cisel SHOULD_BE_EQUAL_FLOAT(-1.5811111+6.5252525, sucet(-1.5811111,6.5252525),"soucet_4"); /** Testovani rozdilu */ // test 5 - celych cisel SHOULD_BE_EQUAL_FLOAT(55.0-20.0, rozdil(55.0,20.0), "rozdil_5"); // test 6 - desetinnych cisel SHOULD_BE_EQUAL_FLOAT( 358.49-258.4, rozdil(358.49,258.4),"rozdil_6"); // test 7 - desetinnych cisel s vetsi presnosti SHOULD_BE_EQUAL_FLOAT(256.12357-128.999999, rozdil(256.12357,128.999999),"rozdil_7"); // test 8 - zapornych desetinnych cisel SHOULD_BE_EQUAL_FLOAT(-2.555555-(-3.595959), rozdil(-2.555555,-3.595959), "rozdil_8"); /** Testovani nasobeni */ // test 9 - celych cisel SHOULD_BE_EQUAL_FLOAT(11.0*3.0, nasobeni(11.0,3.0),"nasobeni_9"); // test 10 - desetinnych cisel SHOULD_BE_EQUAL_FLOAT(35.555*211.652, nasobeni(35.555,211.652),"nasobeni_10"); // test 11 - nasobeni nulou SHOULD_BE_EQUAL_FLOAT(5.5*0.0, nasobeni(5.5,0.0),"nasobeni_11"); // test 12 - nasobeni zapornym cislem SHOULD_BE_EQUAL_FLOAT(36.56*(-4.123), nasobeni(36.56,-4.123),"nasobeni_12"); /** Testovani podilu */ // test 13 - celych cisel SHOULD_BE_EQUAL_FLOAT( 8.0/4.0, podil(8.0,4.0),"podil_13"); // test 14 - desetinnych cisel SHOULD_BE_EQUAL_FLOAT(64.5/28.244, podil(64.5,28.244),"podil_14"); // test 15 - zapornych cisel SHOULD_BE_EQUAL_FLOAT(-96.2/16.5, podil(-96.2,16.5),"podil_15"); // test 16 - podil nulou SHOULD_BE_EQUAL_INF(45.136/0.0,podil(45.136,0.0),"podil_16"); // using isnan() function /** Testovani mocniny */ // test 17 - umocneni celeho cisla SHOULD_BE_EQUAL_FLOAT(pow(5.0,3.0), my_pow(5.0,3.0),"mocnina_17"); // test 18 - umocneni desetinneho cisla SHOULD_BE_EQUAL_FLOAT(pow(25.684,6.0), my_pow(25.684,6),"mocnina_18"); // test 19 - umocneni zapornym cislem SHOULD_BE_EQUAL_NAN(NAN, my_pow(11.6545,-8),"mocnina_19"); // test 20 - umocneni nulou SHOULD_BE_EQUAL_FLOAT(pow(78.1111,0.0), my_pow(78.1111,0),"mocnina_20"); /** Testovani druhe odmocniny */ // test 21 - odmocneni celeho cisla SHOULD_BE_EQUAL_FLOAT(pow(64.0,1/2.0), my_sqrt(64.0), "odmocnina_21"); // test 22 - odmocneni desetinneho cisla SHOULD_BE_EQUAL_FLOAT(pow(235.154787,1/2.0), my_sqrt(235.154787),"odmocnina_22"); // test 23 - odmocneni zaporneho cisla SHOULD_BE_EQUAL_NAN(pow(-81.154787,1/2.0),my_sqrt(-81.154787),"odmocnina_23"); // test 24 - odmocneni nuly SHOULD_BE_EQUAL_FLOAT(pow(0,1/2.0),my_sqrt(0),"odmocnina_24"); /** Testovani arcus sinu */ // test 25 - krajnich hodnot Df SHOULD_BE_EQUAL_FLOAT(asin(1.0), my_asin(1.0),"arcus_sinus_25"); // test 26 - krajnich hodnot Df SHOULD_BE_EQUAL_FLOAT(asin(-1.0), my_asin(-1.0),"arcus_sinus_26"); // test 27 - hodnot z intervalu (-1;1) SHOULD_BE_EQUAL_FLOAT(asin(0.56), my_asin(0.56),"arcus_sinus_27"); // test 28 - hodnot z intervalu (-1;-0.9) a (0.9;1) SHOULD_BE_EQUAL_FLOAT(asin(-0.96), my_asin(-0.96),"arcus_sinus_28"); //test 29 - hodnot mimo definicni obor SHOULD_BE_EQUAL_NAN(NAN,my_asin(-2.56),"arcus_sinus_29"); /** Testovani faktorialu */ // test 30 - kladneho celeho cisla SHOULD_BE_EQUAL_FACT(120.0,factorial(5),"factorial_33"); // test 31 - kladneho celeho cisla SHOULD_BE_EQUAL_FACT(40320.0,factorial(8),"factorial_34"); //test 32 - zaporneho cisla SHOULD_BE_EQUAL_NAN(NAN,factorial(-6),"factorial_35"); // test 33 - cisla s vysledkem nad limit hodnot promenne integer SHOULD_BE_EQUAL_NAN(NAN,factorial(100.0),"factorial_36"); // test 34 - desetinneho cisla SHOULD_BE_EQUAL_NAN(NAN,factorial(29.99),"factorial_37"); /** Testovani absolutni hodnoty */ // test 37 - kladneho celeho cisla SHOULD_BE_EQUAL_FLOAT(fabs(11.0), my_abs(11.0),"my_abs_38"); // test 38 - zaporneho cisla SHOULD_BE_EQUAL_FLOAT(fabs(-222.0), my_abs(-222.0),"my_abs_39"); // test 39 - desetinneho cisla SHOULD_BE_EQUAL_FLOAT(fabs(-55.666), my_abs(-55.666),"my_abs_40"); // test 40 - nuly SHOULD_BE_EQUAL_FLOAT(fabs(0), my_abs(0),"my_abs_41"); printf("\nTest failed: %d\n", errors); printf("Test passed: %d\n",passed); return 0; }
int main(int argc, char *argv[]) { double pole[6]; char* pEnd; if (Argumenty(argc) == EXIT_FAILURE) return EXIT_FAILURE; if (argc == 2 && strcmp("--help", argv[1]) == 0) { Ukoncenie(HELP); return EXIT_SUCCESS; } if(strcmp(argv[1], "--triangle")== 0 && argc==8) { if(Triangle(argv, pole)==EXIT_FAILURE) { printf("%.10e\n%.10e\n%.10e\n", NAN, NAN, NAN); return EXIT_FAILURE; } else return EXIT_SUCCESS; } if(strcmp(argv[1], "--sqrt")== 0 && argc==3) { double x= strtod(argv[2], &pEnd); if(*pEnd == 0) { if(x>=0) { printf("%.10e\n", my_sqrt(x)); return EXIT_SUCCESS; } else printf("%.10e\n", NAN); } else if(strcmp(argv[2], "inf")== 0) { printf("%.10e\n", INF); return EXIT_SUCCESS; } else printf("%.10e\n", NAN); return EXIT_FAILURE; } if(strcmp(argv[1], "--asin")== 0&& argc==3) { double x= strtod(argv[2], &pEnd); if(*pEnd == 0) { if (ab_h(x)<=1.0) /// iba interval x= <-1.0&&x>=-1.0) { printf("%.10e\n", my_asin(x)); return EXIT_SUCCESS; } } printf("%.10e\n", NAN); return EXIT_FAILURE; } Ukoncenie(Args); return EXIT_FAILURE; }
Point resize(double d) { d /= my_sqrt(sqr(x)+sqr(y)); return Point(x*d, y*d); }
int main(int argc, char* argv[]){ #define STACK_17 (void) MAKE_STD_STRING(s,"hello"); #define STACK_19 BOOST_PP_SEQ_PUSH_FRONT(STACK_17, std_string_dest(&s) ) #define STACK_23 BOOST_PP_SEQ_PUSH_FRONT(STACK_19, at_main_scope_exit() ) printf("%s\n",std_string_c_str(&s)); MAKE_STD_VECTOR_int(v); #define STACK_27 BOOST_PP_SEQ_PUSH_FRONT(STACK_23, std_vector_int_dest(&v) ) for(int i=0;i!=30;++i) std_vector_int_push_back(&v,( i * 7 ) % 3); printf("size = %i\n", std_vector_int_size(&v)); printf("capacity = %i\n", std_vector_int_capacity(&v)); for(size_t i=0;i!=std_vector_int_size(&v);++i){ #define STACK_35 (void) MAKE_STD_STRING(s,""); #define STACK_37 BOOST_PP_SEQ_PUSH_FRONT(STACK_35, std_string_dest(&s) ) boost_lexical_cast_int_std_string(&s,i); MAKE_STD_STRING(msg,""); #define STACK_41 BOOST_PP_SEQ_PUSH_FRONT(STACK_37, std_string_dest(&msg) ) std_string_append(&msg,&s); std_string_assign_c(&s," => "); std_string_append(&msg,&s); boost_lexical_cast_int_std_string(&s,std_vector_int_at(&v,i)); std_string_append(&msg,&s); printf("%s%s", i == 0 ? "" : ", ", std_string_begin(&msg)); STACK_UNWIND( STACK_41 ) } for(int i = -10 ; i!= 100;++i){ #define STACK_B69 (void) MAKE_BOOST_OPTIONAL_INT(ret) #define STACK_B71 BOOST_PP_SEQ_PUSH_FRONT( STACK_B69 , boost_optional_int_dest(&ret) ) my_sqrt(&ret,i); MAKE_STD_STRING(s,""); #define STACK_B72 BOOST_PP_SEQ_PUSH_FRONT( STACK_B71 , std_string_dest(&s) ) MAKE_STD_STRING(buf,""); #define STACK_B73 BOOST_PP_SEQ_PUSH_FRONT( STACK_B72 , std_string_dest(&buf) ) boost_lexical_cast_int_std_string( &buf, i ); std_string_append(&s,&buf); std_string_append_c(&s, " => "); if( boost_optional_int_test(&ret) ){ boost_lexical_cast_int_std_string( &buf, *boost_optional_int_get(&ret)); std_string_append(&s,&buf); } else{ std_string_append_c(&s,"(na)"); } printf("%s\n", std_string_begin(&s)); STACK_UNWIND( STACK_B73 ) } printf("\n"); STACK_UNWIND( STACK_27 ) }
int main() { printf ("%g\n", my_sqrt(123.456)); };
static void parse_args(int argc, char *argv[]) { if (argc < 2) { help("missing arguments"); exit(1); } if (argc > 8) { help("too many arguments"); exit(1); } nc = atoi(argv[0]); if (nc < 1) { puts("fairland: error -- number of continents must be > 0"); exit(1); } sc = atoi(argv[1]); if (sc < 1) { puts("fairland: error -- size of continents must be > 0"); exit(1); } if (argc > 2) ni = atoi(argv[2]); else ni = nc; if (argc > 3) is = atoi(argv[3]); else is = sc / 2; if (is < 1) is = 1; if (argc > 4) sp = atoi(argv[4]); else sp = DEFAULT_SPIKE; sp = LIMIT_TO(sp, 0, 100); if (argc > 5) pm = atoi(argv[5]); else pm = DEFAULT_MOUNTAIN; if (pm < 0) pm = 0; if (argc > 6) di = atoi(argv[6]); else di = DEFAULT_CONTDIST; if (di < 0) { puts("fairland: error -- distance between continents must be >= 0"); exit(1); } if (di > WORLD_X / 2 || di > WORLD_Y / 2) { puts("fairland: error -- distance between continents too large"); exit(1); } if (argc > 7) id = atoi(argv[7]); else id = DEFAULT_ISLDIST; if (id < 0) { puts("fairland: error -- distance from islands to continents must be >= 0"); exit(1); } if (id > WORLD_X || id > WORLD_Y) { puts("fairland: error -- distance from islands to continents too large"); exit(1); } if (nc * sc + nc * my_sqrt(sc) * 2 * (di + 1) > WORLD_X * WORLD_Y) { puts("fairland: warning -- world might be too small to fit continents."); puts("arguments should satisfy:"); puts("nc*sc*sc + nc*sqrt(sc)*2*(di+1) < WORLD_X * WORLD_Y"); } }