// +++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++ 自然対数の底e と 円周率π を求めるプログラム +++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++ // // original maked by Y.S. // transfered(fortran to C) by G-HAL // 1995 / 09 / 16 // transfered(C to C++) by G-HAL // 1995 / 09 / 17 // transfered(DECIMAL to BINALY) by G-HAL // 1995 / 09 / 17 // 1995 / 11 / 26 DEBUG // 1995 / 11 / 27 #include "EPPP_C.h" #include #include #include #include // (デフォルトの)求める精度(桁数)を KETAM とする。 signed long KETAM = 1000; // // eを求める // void calE(void) { unsigned long I; LONGNUM ANS, WORK0, WORK1; if( ANS.INIT(KETAM) || WORK0.INIT(KETAM) || WORK1.INIT(KETAM) ) { fputs("ERROR : out of memory.", stderr); exit(-1); } ANS = 1; WORK0 = 1; for( I=1; ; I++) { WORK0 /= I; if( WORK0 == 0 || 65534lEPPP E [length]\n", stderr); fputs("want to get π>EPPP P [length]\n", stderr); fputs("want to get max calclately e>EPPP GE [最大除数]\n", stderr); fputs("want to get max calclately π>EPPP GP [最大除数]\n", stderr); exit(-1); } if(argc == 3) { KETAM = atol(argv[2]); if(!KETAM) { fputs("option error.\n", stderr); exit(-1); } }else puts("default 1000."); argv[1][0] = toupper(argv[1][0]); if(argv[1][0] == 'E') calE(); else if(argv[1][0] == 'P') calPI(); else if(argv[1][0] == 'G'){ double X=0; unsigned long I; argv[1][1] = toupper(argv[1][1]); if(argv[1][1] == 'E'){ for(I=2; I