Lines Matching refs:number
61 static u_long get_ulong(struct number *);
63 static __inline void push_number(struct number *);
67 static __inline struct number *pop_number(void);
87 static u_int count_digits(const struct number *);
108 static bool compare_numbers(enum bcode_compare, struct number *,
109 struct number *);
317 pn(const char *str, const struct number *n)
319 char *p = BN_bn2dec(n->number);
387 split_number(const struct number *n, BIGNUM *i, BIGNUM *f)
391 bn_checkp(BN_copy(i, n->number));
411 bn_check(BN_div(i, f, n->number, a, bmachine.ctx));
418 normalize(struct number *n, u_int s)
420 scale_number(n->number, s - n->scale);
425 get_ulong(struct number *n)
428 return BN_get_word(n->number);
432 negate(struct number *n)
434 BN_set_negative(n->number, !BN_is_negative(n->number));
438 push_number(struct number *n)
467 static __inline struct number *
571 struct number *n;
574 bn_check(BN_set_word(n->number, bmachine.scale));
581 struct number *n;
586 if (BN_is_negative(n->number))
587 warnx("scale must be a nonnegative number");
602 struct number *n;
605 bn_check(BN_set_word(n->number, bmachine.obase));
612 struct number *n;
621 warnx("output base must be a number greater than 1");
629 struct number *n;
632 bn_check(BN_set_word(n->number, bmachine.ibase));
639 struct number *n;
648 warnx("input base must be a number between 2 and 16 "
658 struct number *n;
662 bn_check(BN_set_word(n->number, i));
671 struct number *n;
686 bn_check(BN_set_word(n->number, scale));
692 count_digits(const struct number *n)
699 if (BN_is_zero(n->number))
712 * Estimate number of decimal digits based on number of bits.
747 struct number *n = NULL;
757 bn_check(BN_set_word(n->number, digits));
762 bn_check(BN_set_word(n->number, digits));
775 struct number *n;
786 if (BN_num_bits(n->number) > 8)
787 bn_check(BN_mask_bits(n->number, 8));
788 str[0] = (char)BN_get_word(n->number);
826 struct number *n;
833 bn_check(BN_set_word(n->number, 0));
897 struct number *inumber, *n;
908 if (BN_is_negative(inumber->number))
917 bn_check(BN_set_word(n->number, 0));
930 struct number *inumber;
946 if (BN_is_negative(inumber->number)) {
975 struct number *a, *b;
990 bn_check(BN_add(b->number, a->number, b->number));
998 struct number *a, *b;
1013 bn_check(BN_sub(b->number, b->number, a->number));
1019 bmul_number(struct number *r, struct number *a, struct number *b, u_int scale)
1026 bn_check(BN_mul(r->number, a->number, b->number, bmachine.ctx));
1036 struct number *a, *b;
1055 struct number *a, *b;
1056 struct number *r;
1072 if (BN_is_zero(a->number))
1078 bn_check(BN_div(r->number, NULL, b->number, a->number, bmachine.ctx));
1088 struct number *a, *b;
1089 struct number *r;
1105 if (BN_is_zero(a->number))
1111 bn_check(BN_mod(r->number, b->number, a->number, bmachine.ctx));
1121 struct number *a, *b;
1122 struct number *rdiv, *rmod;
1140 if (BN_is_zero(a->number))
1146 bn_check(BN_div(rdiv->number, rmod->number,
1147 b->number, a->number, bmachine.ctx));
1158 struct number *a, *p;
1159 struct number *r;
1182 BN_free(p->number);
1183 p->number = i;
1187 neg = BN_is_negative(p->number);
1196 b = BN_get_word(p->number);
1204 if (BN_is_zero(p->number)) {
1206 bn_check(BN_one(r->number));
1212 while (!BN_is_bit_set(p->number, 0)) {
1215 bn_check(BN_rshift1(p->number, p->number));
1219 bn_check(BN_rshift1(p->number, p->number));
1222 while (!BN_is_zero(p->number)) {
1225 if (BN_is_bit_set(p->number, 0)) {
1229 bn_check(BN_rshift1(p->number, p->number));
1240 if (BN_is_zero(r->number))
1243 bn_check(BN_div(r->number, NULL, one,
1244 r->number, bmachine.ctx));
1258 struct number *n;
1259 struct number *r;
1267 if (BN_is_zero(n->number)) {
1270 } else if (BN_is_negative(n->number))
1271 warnx("square root of negative number");
1275 x = BN_dup(n->number);
1281 bn_check(BN_div(y, NULL, n->number, x, bmachine.ctx));
1292 r->number = y;
1303 struct number *a;
1309 bn_check(BN_set_word(a->number, BN_get_word(a->number) ? 0 : 1));
1322 struct number *a, *b, *r;
1333 bn_check(BN_set_word(r->number,
1341 struct number *a, *b, *r;
1352 bn_check(BN_set_word(r->number,
1360 struct number *a, *b, *r;
1371 bn_check(BN_set_word(r->number,
1409 compare_numbers(enum bcode_compare type, struct number *a, struct number *b)
1421 cmp = BN_cmp(a->number, b->number);
1447 struct number *a, *b;
1511 struct number *n;
1520 warnx("Q command requires a number >= 1");
1534 struct number *n;
1542 warnx("J command requires a number >= 0");