モジュール | |
| 下位関数群 | |
マクロ定義 | |
| #define | define_ymp_assign_integral_type(type, postfix, sign_check) |
| #define | ymp_assign_zero(self) (void)((self)->used = 0) |
| 多倍長整数に0を代入. より詳しく... | |
関数 | |
| void | ymp_assign (mp_ref_t self, mp_cref_t other) |
| 多倍長整数の値をディープコピーにより代入. より詳しく... | |
| void | ymp_assign_digit (mp_ref_t self, digit_t other) |
| 多倍長整数の値をdigit_tから代入. より詳しく... | |
| void | ymp_assign_array (mp_ref_t self, size_t len, const digit_t *array) |
| 多倍長整数にdigit_tの列から代入. より詳しく... | |
| void | ymp_assign_char (mp_ref_t self, signed char val) |
| 多倍長整数に signed char 型から値を代入. より詳しく... | |
| void | ymp_assign_short (mp_ref_t self, short val) |
| 多倍長整数に short 型から値を代入. より詳しく... | |
| void | ymp_assign_int (mp_ref_t self, int val) |
| 多倍長整数に int 型から値を代入. より詳しく... | |
| void | ymp_assign_long (mp_ref_t self, long val) |
| 多倍長整数に long 型から値を代入. より詳しく... | |
| void | ymp_assign_uchar (mp_ref_t self, unsigned char val) |
| 多倍長整数に unsigned char 型から値を代入. より詳しく... | |
| void | ymp_assign_ushort (mp_ref_t self, unsigned short val) |
| 多倍長整数に unsigned short 型から値を代入. より詳しく... | |
| void | ymp_assign_uint (mp_ref_t self, unsigned int val) |
| 多倍長整数に unsigned int 型から値を代入. より詳しく... | |
| void | ymp_assign_ulong (mp_ref_t self, unsigned long val) |
| 多倍長整数に unsigned long 型から値を代入. より詳しく... | |
| void | ymp_assign_intmax (mp_ref_t self, intmax_t val) |
| 多倍長整数に intmax_t 型から値を代入. より詳しく... | |
| void | ymp_assign_uintmax (mp_ref_t self, uintmax_t val) |
| 多倍長整数に uintmax_t 型から値を代入. より詳しく... | |
| void | ymp_assign_double (mp_ref_t self, double val) |
| 多倍長整数にdouble型から値を代入. より詳しく... | |
| void | ymp_assign_2exp (mp_ref_t self, size_t pow) |
| 多倍長整数に2の冪を代入. より詳しく... | |
| void | ymp_swap (mp_ref_t self, mp_ref_t other) |
| 多倍長整数の値を交換. より詳しく... | |
| void | ymp_assign_string (mp_ref_t self, const char *psz, char **endptr, unsigned radix) |
| 文字列形式で表された整数値をstruct multiprecに代入. より詳しく... | |
|
|
値: \ void ymp_assign_##postfix(mp_ref_t self, type val) \ { \ do_assign_integral_value(type, self, val, ymp_reserve, sign_check); \ } construct.c の 435 行で定義されています。 |
|
|
多倍長整数に0を代入.
multiprec.h の 351 行で定義されています。 |
|
||||||||||||
|
多倍長整数の値をディープコピーにより代入. otherの保持している整数値をselfにディープコピーする。
construct.c の 389 行で定義されています。 参照 mp_cref_t, multiprec::sign, と ymp_assign_abs.
00390 {
00391 self->sign = other->sign;
00392 ymp_assign_abs(self, other);
00393 }
|
|
||||||||||||
|
多倍長整数の値をdigit_tから代入.
construct.c の 404 行で定義されています。 参照 digit_t, positive_sign, multiprec::sign, と ymp_assign_abs_digit.
00405 {
00406 self->sign = positive_sign;
00407 ymp_assign_abs_digit(self, other);
00408 }
|
|
||||||||||||||||
|
多倍長整数にdigit_tの列から代入.
construct.c の 419 行で定義されています。 参照 digit_t, positive_sign, multiprec::sign, と ymp_assign_abs_array.
00420 {
00421 self->sign = positive_sign;
00422 ymp_assign_abs_array(self, len, array);
00423 }
|
|
||||||||||||
|
多倍長整数に signed char 型から値を代入.
construct.c の 447 行で定義されています。 参照 to_sign_check.
00469 {
|
|
||||||||||||
|
多倍長整数に short 型から値を代入.
construct.c の 448 行で定義されています。 参照 to_sign_check.
00469 {
|
|
||||||||||||
|
多倍長整数に int 型から値を代入.
construct.c の 449 行で定義されています。 参照 to_sign_check.
00469 {
|
|
||||||||||||
|
多倍長整数に long 型から値を代入.
construct.c の 450 行で定義されています。 参照 to_sign_check.
00469 {
|
|
||||||||||||
|
多倍長整数に unsigned char 型から値を代入.
construct.c の 451 行で定義されています。
00469 {
|
|
||||||||||||
|
多倍長整数に unsigned short 型から値を代入.
construct.c の 452 行で定義されています。
00469 {
|
|
||||||||||||
|
多倍長整数に unsigned int 型から値を代入.
construct.c の 453 行で定義されています。
00469 {
|
|
||||||||||||
|
多倍長整数に unsigned long 型から値を代入.
construct.c の 454 行で定義されています。
00469 {
|
|
||||||||||||
|
多倍長整数に intmax_t 型から値を代入.
construct.c の 456 行で定義されています。 参照 to_sign_check.
00469 {
|
|
||||||||||||
|
多倍長整数に uintmax_t 型から値を代入.
construct.c の 457 行で定義されています。
00469 {
|
|
||||||||||||
|
多倍長整数にdouble型から値を代入. double型の値の整数部分が代入される。
construct.c の 468 行で定義されています。 参照 do_assign_floating_value, と ymp_reserve.
00469 {
00470 do_assign_floating_value(double,, "ymp_assign_by_double", ymp_reserve);
00471 }
|
|
||||||||||||
|
多倍長整数に2の冪を代入. <self> := 2**pow
construct.c の 481 行で定義されています。 参照 DIGIT_BIT, digit_t, multiprec::digits, positive_sign, multiprec::sign, multiprec::used, と ymp_reserve.
00482 {
00483 size_t n_digits = pow / DIGIT_BIT, n_bits = pow % DIGIT_BIT;
00484
00485 self->sign = positive_sign;
00486 ymp_reserve(self, n_digits+1);
00487 self->used = n_digits + 1;
00488 memset(self->digits, 0, sizeof(digit_t)*n_digits);
00489 self->digits[n_digits] = 1u << n_bits;
00490 }
|
|
||||||||||||
|
多倍長整数の値を交換. selfとotherがそれぞれ保持している整数値を交換する construct.c の 499 行で定義されています。 参照 digit_t, multiprec::digits, multiprec::len, mp_sign_t, multiprec::sign, と multiprec::used.
00500 {
00501 enum mp_sign_t tmp_sign;
00502 size_t tmp_size;
00503 digit_t *tmp_digits;
00504
00505 tmp_sign = self->sign;
00506 self->sign = other->sign;
00507 other->sign = tmp_sign;
00508
00509 tmp_size = self->len;
00510 self->len = other->len;
00511 other->len = tmp_size;
00512
00513 tmp_size = self->used;
00514 self->used = other->used;
00515 other->used = tmp_size;
00516
00517 tmp_digits = self->digits;
00518 self->digits = other->digits;
00519 other->digits = tmp_digits;
00520 }
|
|
||||||||||||||||||||
|
文字列形式で表された整数値をstruct multiprecに代入. 引数のの意味はstrtol(), strtoul()と同じ
construct_str.c の 32 行で定義されています。 参照 digit_t, multiprec::digits, MULTIPREC_RADIX, negative_sign, positive_sign, multiprec::sign, multiprec::used, ymp_addabs, ymp_error, ymp_mulabs_digit, と ymp_reserve.
00034 {
00035 if (radix > 36)
00036 ymp_error("文字列からの変換の基数が大きすぎる: %u", radix);
00037
00038 switch (*psz)
00039 {
00040 case '-':
00041 ++psz;
00042 self->sign = negative_sign;
00043 break;
00044 case '+':
00045 ++psz; /* no break */
00046 default:
00047 self->sign = positive_sign;
00048 }
00049
00050 if (radix == 0)
00051 {
00052 if (*psz != '0') radix = 10;
00053 else switch (*++psz)
00054 {
00055 case 'B': case 'b': radix = 2; ++psz; break;
00056 case 'Q': case 'q': radix = 4; ++psz; break;
00057 case 'O': case 'o': radix = 8; ++psz; break;
00058 case 'D': case 'd': radix = 10; ++psz; break;
00059 case 'X': case 'x': radix = 16; ++psz; break;
00060 default: radix = 8; break;
00061 }
00062 }
00063
00064 ymp_reserve(self, ceil(strlen(psz)*(log(radix)/log(MULTIPREC_RADIX)))+1);
00065
00066 self->used = 0; self->digits[0] = 0;
00067 for ( ; *psz; ++psz)
00068 {
00069 digit_t c;
00070 switch (*psz)
00071 {
00072 case '0': c = 0; break; case '1': c = 1; break;
00073 case '2': c = 2; break; case '3': c = 3; break;
00074 case '4': c = 4; break; case '5': c = 5; break;
00075 case '6': c = 6; break; case '7': c = 7; break;
00076 case '8': c = 8; break; case '9': c = 9; break;
00077 case 'A': case 'a': c = 10; break;
00078 case 'B': case 'b': c = 11; break;
00079 case 'C': case 'c': c = 12; break;
00080 case 'D': case 'd': c = 13; break;
00081 case 'E': case 'e': c = 14; break;
00082 case 'F': case 'f': c = 15; break;
00083 case 'G': case 'g': c = 16; break;
00084 case 'H': case 'h': c = 17; break;
00085 case 'I': case 'i': c = 18; break;
00086 case 'J': case 'j': c = 19; break;
00087 case 'K': case 'k': c = 20; break;
00088 case 'L': case 'l': c = 21; break;
00089 case 'M': case 'm': c = 22; break;
00090 case 'N': case 'n': c = 23; break;
00091 case 'O': case 'o': c = 24; break;
00092 case 'P': case 'p': c = 25; break;
00093 case 'Q': case 'q': c = 26; break;
00094 case 'R': case 'r': c = 27; break;
00095 case 'S': case 's': c = 28; break;
00096 case 'T': case 't': c = 29; break;
00097 case 'U': case 'u': c = 30; break;
00098 case 'V': case 'v': c = 31; break;
00099 case 'W': case 'w': c = 32; break;
00100 case 'X': case 'x': c = 33; break;
00101 case 'Y': case 'y': c = 34; break;
00102 case 'Z': case 'z': c = 35; break;
00103
00104 case '_': continue;
00105 default: c = 127;
00106 }
00107 if (c >= radix) break;
00108
00109 ymp_reserve(self, self->used+1);
00110 self->used
00111 = ymp_mulabs_digit(self->digits, self->digits, radix, self->used);
00112 self->used
00113 = ymp_addabs(self->digits, self->digits, &c, self->used, 1);
00114 }
00115
00116 if (endptr) *endptr = (char*)psz;
00117 }
|
1.2.14 作者 Dimitri van Heesch,
© 1997-2002