Lines Matching full:bignum
33 #include "src/bignum.h"
41 static void AssignHexString(Bignum* bignum, const char* str) {
42 bignum->AssignHexString(Vector<const char>(str, StrLength(str)));
46 static void AssignDecimalString(Bignum* bignum, const char* str) {
47 bignum->AssignDecimalString(Vector<const char>(str, StrLength(str)));
53 Bignum bignum;
54 Bignum bignum2;
55 bignum.AssignUInt16(0);
56 CHECK(bignum.ToHexString(buffer, kBufferSize));
58 bignum.AssignUInt16(0xA);
59 CHECK(bignum.ToHexString(buffer, kBufferSize));
61 bignum.AssignUInt16(0x20);
62 CHECK(bignum.ToHexString(buffer, kBufferSize));
66 bignum.AssignUInt64(0);
67 CHECK(bignum.ToHexString(buffer, kBufferSize));
69 bignum.AssignUInt64(0xA);
70 CHECK(bignum.ToHexString(buffer, kBufferSize));
72 bignum.AssignUInt64(0x20);
73 CHECK(bignum.ToHexString(buffer, kBufferSize));
75 bignum.AssignUInt64(0x100);
76 CHECK(bignum.ToHexString(buffer, kBufferSize));
80 bignum.AssignUInt64(0x12345678);
81 CHECK(bignum.ToHexString(buffer, kBufferSize));
85 bignum.AssignUInt64(big);
86 CHECK(bignum.ToHexString(buffer, kBufferSize));
90 bignum.AssignUInt64(big);
91 CHECK(bignum.ToHexString(buffer, kBufferSize));
94 bignum2.AssignBignum(bignum);
98 AssignDecimalString(&bignum, "0");
99 CHECK(bignum.ToHexString(buffer, kBufferSize));
102 AssignDecimalString(&bignum, "1");
103 CHECK(bignum.ToHexString(buffer, kBufferSize));
106 AssignDecimalString(&bignum, "1234567890");
107 CHECK(bignum.ToHexString(buffer, kBufferSize));
110 AssignHexString(&bignum, "0");
111 CHECK(bignum.ToHexString(buffer, kBufferSize));
114 AssignHexString(&bignum, "123456789ABCDEF0");
115 CHECK(bignum.ToHexString(buffer, kBufferSize));
122 Bignum bignum;
123 AssignHexString(&bignum, "0");
124 bignum.ShiftLeft(100);
125 CHECK(bignum.ToHexString(buffer, kBufferSize));
128 AssignHexString(&bignum, "1");
129 bignum.ShiftLeft(1);
130 CHECK(bignum.ToHexString(buffer, kBufferSize));
133 AssignHexString(&bignum, "1");
134 bignum.ShiftLeft(4);
135 CHECK(bignum.ToHexString(buffer, kBufferSize));
138 AssignHexString(&bignum, "1");
139 bignum.ShiftLeft(32);
140 CHECK(bignum.ToHexString(buffer, kBufferSize));
143 AssignHexString(&bignum, "1");
144 bignum.ShiftLeft(64);
145 CHECK(bignum.ToHexString(buffer, kBufferSize));
148 AssignHexString(&bignum, "123456789ABCDEF");
149 bignum.ShiftLeft(64);
150 CHECK(bignum.ToHexString(buffer, kBufferSize));
152 bignum.ShiftLeft(1);
153 CHECK(bignum.ToHexString(buffer, kBufferSize));
160 Bignum bignum;
161 AssignHexString(&bignum, "0");
162 bignum.AddUInt64(0xA);
163 CHECK(bignum.ToHexString(buffer, kBufferSize));
166 AssignHexString(&bignum, "1");
167 bignum.AddUInt64(0xA);
168 CHECK(bignum.ToHexString(buffer, kBufferSize));
171 AssignHexString(&bignum, "1");
172 bignum.AddUInt64(0x100);
173 CHECK(bignum.ToHexString(buffer, kBufferSize));
176 AssignHexString(&bignum, "1");
177 bignum.AddUInt64(0xFFFF);
178 CHECK(bignum.ToHexString(buffer, kBufferSize));
181 AssignHexString(&bignum, "FFFFFFF");
182 bignum.AddUInt64(0x1);
183 CHECK(bignum.ToHexString(buffer, kBufferSize));
186 AssignHexString(&bignum, "10000000000000000000000000000000000000000000");
187 bignum.AddUInt64(0xFFFF);
188 CHECK(bignum.ToHexString(buffer, kBufferSize));
191 AssignHexString(&bignum, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
192 bignum.AddUInt64(0x1);
193 CHECK(bignum.ToHexString(buffer, kBufferSize));
196 bignum.AssignUInt16(0x1);
197 bignum.ShiftLeft(100);
198 bignum.AddUInt64(1);
199 CHECK(bignum.ToHexString(buffer, kBufferSize));
202 bignum.AssignUInt16(0x1);
203 bignum.ShiftLeft(100);
204 bignum.AddUInt64(0xFFFF);
205 CHECK(bignum.ToHexString(buffer, kBufferSize));
208 AssignHexString(&bignum, "0");
209 bignum.AddUInt64(V8_2PART_UINT64_C(0xA, 00000000));
210 CHECK(bignum.ToHexString(buffer, kBufferSize));
213 AssignHexString(&bignum, "1");
214 bignum.AddUInt64(V8_2PART_UINT64_C(0xA, 00000000));
215 CHECK(bignum.ToHexString(buffer, kBufferSize));
218 AssignHexString(&bignum, "1");
219 bignum.AddUInt64(V8_2PART_UINT64_C(0x100, 00000000));
220 CHECK(bignum.ToHexString(buffer, kBufferSize));
223 AssignHexString(&bignum, "1");
224 bignum.AddUInt64(V8_2PART_UINT64_C(0xFFFF, 00000000));
225 CHECK(bignum.ToHexString(buffer, kBufferSize));
228 AssignHexString(&bignum, "FFFFFFF");
229 bignum.AddUInt64(V8_2PART_UINT64_C(0x1, 00000000));
230 CHECK(bignum.ToHexString(buffer, kBufferSize));
233 AssignHexString(&bignum, "10000000000000000000000000000000000000000000");
234 bignum.AddUInt64(V8_2PART_UINT64_C(0xFFFF, 00000000));
235 CHECK(bignum.ToHexString(buffer, kBufferSize));
238 AssignHexString(&bignum, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
239 bignum.AddUInt64(V8_2PART_UINT64_C(0x1, 00000000));
240 CHECK(bignum.ToHexString(buffer, kBufferSize));
243 bignum.AssignUInt16(0x1);
244 bignum.ShiftLeft(100);
245 bignum.AddUInt64(V8_2PART_UINT64_C(0x1, 00000000));
246 CHECK(bignum.ToHexString(buffer, kBufferSize));
249 bignum.AssignUInt16(0x1);
250 bignum.ShiftLeft(100);
251 bignum.AddUInt64(V8_2PART_UINT64_C(0xFFFF, 00000000));
252 CHECK(bignum.ToHexString(buffer, kBufferSize));
259 Bignum bignum;
260 Bignum other;
263 AssignHexString(&bignum, "0");
264 bignum.AddBignum(other);
265 CHECK(bignum.ToHexString(buffer, kBufferSize));
268 AssignHexString(&bignum, "1");
269 bignum.AddBignum(other);
270 CHECK(bignum.ToHexString(buffer, kBufferSize));
273 AssignHexString(&bignum, "FFFFFFF");
274 bignum.AddBignum(other);
275 CHECK(bignum.ToHexString(buffer, kBufferSize));
278 AssignHexString(&bignum, "FFFFFFFFFFFFFF");
279 bignum.AddBignum(other);
280 CHECK(bignum.ToHexString(buffer, kBufferSize));
283 AssignHexString(&bignum, "10000000000000000000000000000000000000000000");
284 bignum.AddBignum(other);
285 CHECK(bignum.ToHexString(buffer, kBufferSize));
290 AssignHexString(&bignum, "1");
291 bignum.AddBignum(other);
292 CHECK(bignum.ToHexString(buffer, kBufferSize));
295 AssignHexString(&bignum, "FFFFFFF");
296 bignum.AddBignum(other);
297 CHECK(bignum.ToHexString(buffer, kBufferSize));
300 AssignHexString(&bignum, "10000000000000000000000000000000000000000000");
301 bignum.AddBignum(other);
302 CHECK(bignum.ToHexString(buffer, kBufferSize));
305 AssignHexString(&bignum, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
306 bignum.AddBignum(other);
307 CHECK(bignum.ToHexString(buffer, kBufferSize));
310 bignum.AssignUInt16(0x1);
311 bignum.ShiftLeft(100);
312 bignum.AddBignum(other);
313 CHECK(bignum.ToHexString(buffer, kBufferSize));
319 bignum.AssignUInt16(0x1);
320 bignum.AddBignum(other);
321 CHECK(bignum.ToHexString(buffer, kBufferSize));
324 AssignHexString(&bignum, "FFFFFFF");
325 bignum.AddBignum(other);
326 CHECK(bignum.ToHexString(buffer, kBufferSize));
329 AssignHexString(&bignum, "10000000000000000000000000000000000000000000");
330 bignum.AddBignum(other);
331 CHECK(bignum.ToHexString(buffer, kBufferSize));
334 AssignHexString(&bignum, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
335 bignum.AddBignum(other);
336 CHECK(bignum.ToHexString(buffer, kBufferSize));
339 bignum.AssignUInt16(0x1);
340 bignum.ShiftLeft(100);
341 bignum.AddBignum(other);
342 CHECK(bignum.ToHexString(buffer, kBufferSize));
349 Bignum bignum;
350 Bignum other;
352 AssignHexString(&bignum, "1");
354 bignum.SubtractBignum(other);
355 CHECK(bignum.ToHexString(buffer, kBufferSize));
358 AssignHexString(&bignum, "2");
360 bignum.SubtractBignum(other);
361 CHECK(bignum.ToHexString(buffer, kBufferSize));
364 AssignHexString(&bignum, "10000000");
366 bignum.SubtractBignum(other);
367 CHECK(bignum.ToHexString(buffer, kBufferSize));
370 AssignHexString(&bignum, "100000000000000");
372 bignum.SubtractBignum(other);
373 CHECK(bignum.ToHexString(buffer, kBufferSize));
376 AssignHexString(&bignum, "10000000000000000000000000000000000000000001");
378 bignum.SubtractBignum(other);
379 CHECK(bignum.ToHexString(buffer, kBufferSize));
382 AssignHexString(&bignum, "1000000000001");
384 bignum.SubtractBignum(other);
385 CHECK(bignum.ToHexString(buffer, kBufferSize));
388 AssignHexString(&bignum, "100000FFFFFFF");
390 bignum.SubtractBignum(other);
391 CHECK(bignum.ToHexString(buffer, kBufferSize));
394 AssignHexString(&bignum, "10000000000000000000000000000001000000000000");
396 bignum.SubtractBignum(other);
397 CHECK(bignum.ToHexString(buffer, kBufferSize));
400 AssignHexString(&bignum, "1000000000000000000000000000000FFFFFFFFFFFF");
402 bignum.SubtractBignum(other);
403 CHECK(bignum.ToHexString(buffer, kBufferSize));
406 bignum.AssignUInt16(0x1);
407 bignum.ShiftLeft(100);
410 bignum.SubtractBignum(other);
411 CHECK(bignum.ToHexString(buffer, kBufferSize));
418 bignum.AssignUInt16(0x1);
419 bignum.ShiftLeft(100);
420 // bignum == "10000000000000000000000000"
421 bignum.SubtractBignum(other);
422 CHECK(bignum.ToHexString(buffer, kBufferSize));
428 AssignHexString(&bignum, "FFFFFFF");
429 bignum.ShiftLeft(60);
430 // bignum = FFFFFFF000000000000000
431 bignum.SubtractBignum(other);
432 CHECK(bignum.ToHexString(buffer, kBufferSize));
435 AssignHexString(&bignum, "10000000000000000000000000000000000000000000");
436 bignum.SubtractBignum(other);
437 CHECK(bignum.ToHexString(buffer, kBufferSize));
440 AssignHexString(&bignum, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
441 bignum.SubtractBignum(other);
442 CHECK(bignum.ToHexString(buffer, kBufferSize));
449 Bignum bignum;
451 AssignHexString(&bignum, "0");
452 bignum.MultiplyByUInt32(0x25);
453 CHECK(bignum.ToHexString(buffer, kBufferSize));
456 AssignHexString(&bignum, "2");
457 bignum.MultiplyByUInt32(0x5);
458 CHECK(bignum.ToHexString(buffer, kBufferSize));
461 AssignHexString(&bignum, "10000000");
462 bignum.MultiplyByUInt32(0x9);
463 CHECK(bignum.ToHexString(buffer, kBufferSize));
466 AssignHexString(&bignum, "100000000000000");
467 bignum.MultiplyByUInt32(0xFFFF);
468 CHECK(bignum.ToHexString(buffer, kBufferSize));
471 AssignHexString(&bignum
472 bignum.MultiplyByUInt32(0xFFFFFFFF);
473 CHECK(bignum.ToHexString(buffer, kBufferSize));
476 AssignHexString(&bignum, "1234567ABCD");
477 bignum.MultiplyByUInt32(0xFFF);
478 CHECK(bignum.ToHexString(buffer, kBufferSize));
481 AssignHexString(&bignum, "1234567ABCD");
482 bignum.MultiplyByUInt32(0xFFFFFFF);
483 CHECK(bignum.ToHexString(buffer, kBufferSize));
486 AssignHexString(&bignum, "FFFFFFFFFFFFFFFF");
487 bignum.MultiplyByUInt32(0x2);
488 CHECK(bignum.ToHexString(buffer, kBufferSize));
491 AssignHexString(&bignum, "FFFFFFFFFFFFFFFF");
492 bignum.MultiplyByUInt32(0x4);
493 CHECK(bignum.ToHexString(buffer, kBufferSize));
496 AssignHexString(&bignum, "FFFFFFFFFFFFFFFF");
497 bignum.MultiplyByUInt32(0xF);
498 CHECK(bignum.ToHexString(buffer, kBufferSize));
501 AssignHexString(&bignum, "FFFFFFFFFFFFFFFF");
502 bignum.MultiplyByUInt32(0xFFFFFF);
503 CHECK(bignum.ToHexString(buffer, kBufferSize));
506 bignum.AssignUInt16(0x1);
507 bignum.ShiftLeft(100);
509 bignum.MultiplyByUInt32(2);
510 CHECK(bignum.ToHexString(buffer, kBufferSize));
513 bignum.AssignUInt16(0x1);
514 bignum.ShiftLeft(100);
516 bignum.MultiplyByUInt32(0xF);
517 CHECK(bignum.ToHexString(buffer, kBufferSize));
520 bignum.AssignUInt16(0xFFFF);
521 bignum.ShiftLeft(100);
523 bignum.MultiplyByUInt32(0xFFFF);
524 CHECK(bignum.ToHexString(buffer, kBufferSize));
527 bignum.AssignUInt16(0xFFFF);
528 bignum.ShiftLeft(100);
530 bignum.MultiplyByUInt32(0xFFFFFFFF);
531 CHECK(bignum.ToHexString(buffer, kBufferSize));
534 bignum.AssignUInt16(0xFFFF);
535 bignum.ShiftLeft(100);
537 bignum.MultiplyByUInt32(0xFFFFFFFF);
538 CHECK(bignum.ToHexString(buffer, kBufferSize));
541 AssignDecimalString(&bignum, "15611230384529777");
542 bignum.MultiplyByUInt32(10000000);
543 CHECK(bignum.ToHexString(buffer, kBufferSize));
550 Bignum bignum;
552 AssignHexString(&bignum, "0");
553 bignum.MultiplyByUInt64(0x25);
554 CHECK(bignum.ToHexString(buffer, kBufferSize));
557 AssignHexString(&bignum, "2");
558 bignum.MultiplyByUInt64(0x5);
559 CHECK(bignum.ToHexString(buffer, kBufferSize));
562 AssignHexString(&bignum, "10000000");
563 bignum.MultiplyByUInt64(0x9);
564 CHECK(bignum.ToHexString(buffer, kBufferSize));
567 AssignHexString(&bignum, "100000000000000");
568 bignum.MultiplyByUInt64(0xFFFF);
569 CHECK(bignum.ToHexString(buffer, kBufferSize));
572 AssignHexString(&bignum, "100000000000000");
573 bignum.MultiplyByUInt64(V8_2PART_UINT64_C(0xFFFFFFFF, FFFFFFFF));
574 CHECK(bignum.ToHexString(buffer, kBufferSize));
577 AssignHexString(&bignum, "1234567ABCD");
578 bignum.MultiplyByUInt64(0xFFF);
579 CHECK(bignum.ToHexString(buffer, kBufferSize));
582 AssignHexString(&bignum, "1234567ABCD");
583 bignum.MultiplyByUInt64(V8_2PART_UINT64_C(0xFF, FFFFFFFF));
584 CHECK(bignum.ToHexString(buffer, kBufferSize));
587 AssignHexString(&bignum, "FFFFFFFFFFFFFFFF");
588 bignum.MultiplyByUInt64(0x2);
589 CHECK(bignum.ToHexString(buffer, kBufferSize));
592 AssignHexString(&bignum, "FFFFFFFFFFFFFFFF");
593 bignum.MultiplyByUInt64(0x4);
594 CHECK(bignum.ToHexString(buffer, kBufferSize));
597 AssignHexString(&bignum, "FFFFFFFFFFFFFFFF");
598 bignum.MultiplyByUInt64(0xF);
599 CHECK(bignum.ToHexString(buffer, kBufferSize));
602 AssignHexString(&bignum, "FFFFFFFFFFFFFFFF");
603 bignum.MultiplyByUInt64(V8_2PART_UINT64_C(0xFFFFFFFF, FFFFFFFF));
604 CHECK(bignum.ToHexString(buffer, kBufferSize));
607 bignum.AssignUInt16(0x1);
608 bignum.ShiftLeft(100);
610 bignum.MultiplyByUInt64(2);
611 CHECK(bignum.ToHexString(buffer, kBufferSize));
614 bignum.AssignUInt16(0x1);
615 bignum.ShiftLeft(100);
617 bignum.MultiplyByUInt64(0xF);
618 CHECK(bignum.ToHexString(buffer, kBufferSize));
621 bignum.AssignUInt16(0xFFFF);
622 bignum.ShiftLeft(100);
624 bignum.MultiplyByUInt64(0xFFFF);
625 CHECK(bignum.ToHexString(buffer, kBufferSize));
628 bignum.AssignUInt16(0xFFFF);
629 bignum.ShiftLeft(100);
631 bignum.MultiplyByUInt64(0xFFFFFFFF);
632 CHECK(bignum.ToHexString(buffer, kBufferSize));
635 bignum.AssignUInt16(0xFFFF);
636 bignum.ShiftLeft(100);
638 bignum.MultiplyByUInt64(V8_2PART_UINT64_C(0xFFFFFFFF, FFFFFFFF));
639 CHECK(bignum.ToHexString(buffer, kBufferSize));
642 AssignDecimalString(&bignum, "15611230384529777");
643 bignum.MultiplyByUInt64(V8_2PART_UINT64_C(0x8ac72304, 89e80000));
644 CHECK(bignum.ToHexString(buffer, kBufferSize));
651 Bignum bignum;
653 AssignDecimalString(&bignum, "1234");
654 bignum.MultiplyByPowerOfTen(1);
655 CHECK(bignum.ToHexString(buffer, kBufferSize));
658 AssignDecimalString(&bignum, "1234");
659 bignum.MultiplyByPowerOfTen(2);
660 CHECK(bignum.ToHexString(buffer, kBufferSize));
663 AssignDecimalString(&bignum, "1234");
664 bignum.MultiplyByPowerOfTen(3);
665 CHECK(bignum.ToHexString(buffer, kBufferSize));
668 AssignDecimalString(&bignum, "1234");
669 bignum.MultiplyByPowerOfTen(4);
670 CHECK(bignum.ToHexString(buffer, kBufferSize));
673 AssignDecimalString(&bignum, "1234");
674 bignum.MultiplyByPowerOfTen(5);
675 CHECK(bignum.ToHexString(buffer, kBufferSize));
678 AssignDecimalString(&bignum, "1234");
679 bignum.MultiplyByPowerOfTen(6);
680 CHECK(bignum.ToHexString(buffer, kBufferSize));
683 AssignDecimalString(&bignum, "1234");
684 bignum.MultiplyByPowerOfTen(7);
685 CHECK(bignum.ToHexString(buffer, kBufferSize));
688 AssignDecimalString(&bignum, "1234");
689 bignum.MultiplyByPowerOfTen(8);
690 CHECK(bignum.ToHexString(buffer, kBufferSize));
693 AssignDecimalString(&bignum, "1234");
694 bignum.MultiplyByPowerOfTen(9);
695 CHECK(bignum.ToHexString(buffer, kBufferSize));
698 AssignDecimalString(&bignum, "1234");
699 bignum.MultiplyByPowerOfTen(10);
700 CHECK(bignum.ToHexString(buffer, kBufferSize));
703 AssignDecimalString(&bignum, "1234");
704 bignum.MultiplyByPowerOfTen(11);
705 CHECK(bignum.ToHexString(buffer, kBufferSize));
708 AssignDecimalString(&bignum, "1234");
709 bignum.MultiplyByPowerOfTen(12);
710 CHECK(bignum.ToHexString(buffer, kBufferSize));
713 AssignDecimalString(&bignum, "1234");
714 bignum.MultiplyByPowerOfTen(13);
715 CHECK(bignum.ToHexString(buffer, kBufferSize));
718 AssignDecimalString(&bignum, "1234");
719 bignum.MultiplyByPowerOfTen(14);
720 CHECK(bignum.ToHexString(buffer, kBufferSize));
723 AssignDecimalString(&bignum, "1234");
724 bignum.MultiplyByPowerOfTen(15);
725 CHECK(bignum.ToHexString(buffer, kBufferSize));
728 AssignDecimalString(&bignum, "1234");
729 bignum.MultiplyByPowerOfTen(16);
730 CHECK(bignum.ToHexString(buffer, kBufferSize));
733 AssignDecimalString(&bignum, "1234");
734 bignum.MultiplyByPowerOfTen(17);
735 CHECK(bignum.ToHexString(buffer, kBufferSize));
738 AssignDecimalString(&bignum, "1234");
739 bignum.MultiplyByPowerOfTen(18);
740 CHECK(bignum.ToHexString(buffer, kBufferSize));
743 AssignDecimalString(&bignum, "1234");
744 bignum.MultiplyByPowerOfTen(19);
745 CHECK(bignum.ToHexString(buffer, kBufferSize));
748 AssignDecimalString(&bignum, "1234");
749 bignum.MultiplyByPowerOfTen(20);
750 CHECK(bignum.ToHexString(buffer, kBufferSize));
753 AssignDecimalString(&bignum, "1234");
754 bignum.MultiplyByPowerOfTen(21);
755 CHECK(bignum.ToHexString(buffer, kBufferSize));
758 AssignDecimalString(&bignum, "1234");
759 bignum.MultiplyByPowerOfTen(22);
760 CHECK(bignum.ToHexString(buffer, kBufferSize));
763 AssignDecimalString(&bignum, "1234");
764 bignum.MultiplyByPowerOfTen(23);
765 CHECK(bignum.ToHexString(buffer, kBufferSize));
768 AssignDecimalString(&bignum, "1234");
769 bignum.MultiplyByPowerOfTen(24);
770 CHECK(bignum.ToHexString(buffer, kBufferSize));
773 AssignDecimalString(&bignum, "1234");
774 bignum.MultiplyByPowerOfTen(25);
775 CHECK(bignum.ToHexString(buffer, kBufferSize));
778 AssignDecimalString(&bignum, "1234");
779 bignum.MultiplyByPowerOfTen(26);
780 CHECK(bignum.ToHexString(buffer, kBufferSize));
783 AssignDecimalString(&bignum, "1234");
784 bignum.MultiplyByPowerOfTen(27);
785 CHECK(bignum.ToHexString(buffer, kBufferSize));
788 AssignDecimalString(&bignum, "1234");
789 bignum.MultiplyByPowerOfTen(28);
790 CHECK(bignum.ToHexString(buffer, kBufferSize));
793 AssignDecimalString(&bignum, "1234");
794 bignum.MultiplyByPowerOfTen(29);
795 CHECK(bignum.ToHexString(buffer, kBufferSize));
798 AssignDecimalString(&bignum, "1234");
799 bignum.MultiplyByPowerOfTen(30);
800 CHECK(bignum.ToHexString(buffer, kBufferSize));
803 AssignDecimalString(&bignum, "1234");
804 bignum.MultiplyByPowerOfTen(31);
805 CHECK(bignum.ToHexString(buffer, kBufferSize));
808 AssignDecimalString(&bignum, "1234");
809 bignum.MultiplyByPowerOfTen(50);
810 CHECK(bignum.ToHexString(buffer, kBufferSize));
813 AssignDecimalString(&bignum, "1234");
814 bignum.MultiplyByPowerOfTen(100);
815 CHECK(bignum.ToHexString(buffer, kBufferSize));
822 AssignDecimalString(&bignum, "1234");
823 bignum.MultiplyByPowerOfTen(200);
824 CHECK(bignum.ToHexString(buffer, kBufferSize));
832 AssignDecimalString(&bignum, "1234");
833 bignum.MultiplyByPowerOfTen(500);
834 CHECK(bignum.ToHexString(buffer, kBufferSize));
846 AssignDecimalString(&bignum, "1234");
847 bignum.MultiplyByPowerOfTen(1000);
848 CHECK(bignum.ToHexString(buffer, kBufferSize));
867 Bignum bignum2;
890 bignum.AssignBignum(bignum2);
891 bignum.MultiplyByPowerOfTen(1);
892 CHECK(bignum
904 bignum.AssignBignum(bignum2);
905 bignum.MultiplyByPowerOfTen(2);
906 CHECK(bignum.ToHexString(buffer, kBufferSize));
918 bignum.AssignBignum(bignum2);
919 bignum.MultiplyByPowerOfTen(5);
920 CHECK(bignum.ToHexString(buffer, kBufferSize));
932 bignum.AssignBignum(bignum2);
933 bignum.MultiplyByPowerOfTen(10);
934 CHECK(bignum.ToHexString(buffer, kBufferSize));
946 bignum.AssignBignum(bignum2);
947 bignum.MultiplyByPowerOfTen(50);
948 CHECK(bignum.ToHexString(buffer, kBufferSize));
961 bignum.AssignBignum(bignum2);
962 bignum.MultiplyByPowerOfTen(100);
963 CHECK(bignum.ToHexString(buffer, kBufferSize));
977 bignum.AssignBignum(bignum2);
978 bignum.MultiplyByPowerOfTen(200);
979 CHECK(bignum.ToHexString(buffer, kBufferSize));
994 bignum.AssignBignum(bignum2);
995 bignum.MultiplyByPowerOfTen(500);
996 CHECK(bignum.ToHexString(buffer, kBufferSize));
1019 Bignum bignum;
1020 Bignum other;
1021 Bignum third;
1023 bignum.AssignUInt16(10);
1025 CHECK_EQ(5, bignum.DivideModuloIntBignum(other));
1026 CHECK(bignum.ToHexString(buffer, kBufferSize));
1029 bignum.AssignUInt16(10);
1030 bignum.ShiftLeft(500);
1033 CHECK_EQ(5, bignum.DivideModuloIntBignum(other));
1036 bignum.AssignUInt16(11);
1038 CHECK_EQ(5, bignum.DivideModuloIntBignum(other));
1039 CHECK(bignum.ToHexString(buffer, kBufferSize));
1042 bignum.AssignUInt16(10);
1043 bignum.ShiftLeft(500);
1045 bignum.AddBignum(other);
1048 CHECK_EQ(5, bignum.DivideModuloIntBignum(other));
1049 CHECK(bignum.ToHexString(buffer, kBufferSize));
1052 bignum.AssignUInt16(10);
1053 bignum.ShiftLeft(500);
1054 other.AssignBignum(bignum);
1055 bignum.MultiplyByUInt32(0x1234);
1057 bignum.AddBignum(third);
1058 CHECK_EQ(0x1234, bignum.DivideModuloIntBignum(other));
1059 CHECK(bignum.ToHexString(buffer, kBufferSize));
1062 bignum.AssignUInt16(10);
1064 CHECK_EQ(0, bignum.DivideModuloIntBignum(other));
1065 CHECK(bignum.ToHexString(buffer, kBufferSize));
1068 AssignHexString(&bignum, "12345678");
1070 CHECK_EQ(5, bignum.DivideModuloIntBignum(other));
1071 CHECK(bignum.ToHexString(buffer, kBufferSize));
1074 AssignHexString(&bignum, "70000001");
1076 CHECK_EQ(3, bignum.DivideModuloIntBignum(other));
1077 CHECK(bignum.ToHexString(buffer, kBufferSize));
1080 AssignHexString(&bignum, "28000000");
1082 CHECK_EQ(2, bignum.DivideModuloIntBignum(other));
1083 CHECK(bignum.ToHexString(buffer, kBufferSize));
1086 bignum.AssignUInt16(10);
1087 bignum.ShiftLeft(500);
1088 other.AssignBignum(bignum);
1089 bignum.MultiplyByUInt32(0x1234);
1092 CHECK_EQ(0x1234, bignum.DivideModuloIntBignum(other));
1093 CHECK(bignum.ToHexString(buffer, kBufferSize));
1095 CHECK_EQ(0, bignum.DivideModuloIntBignum(other));
1096 CHECK(bignum.ToHexString(buffer, kBufferSize));
1102 Bignum bignum1;
1103 Bignum bignum2;
1106 CHECK_EQ(0, Bignum::Compare(bignum1, bignum2));
1107 CHECK(Bignum::Equal(bignum1, bignum2));
1108 CHECK(Bignum::LessEqual(bignum1, bignum2));
1109 CHECK(!Bignum::Less(bignum1, bignum2));
1113 CHECK_EQ(-1, Bignum::Compare(bignum1, bignum2));
1114 CHECK_EQ(+1, Bignum::Compare(bignum2, bignum1));
1115 CHECK(!Bignum::Equal(bignum1, bignum2));
1116 CHECK(!Bignum::Equal(bignum2, bignum1));
1117 CHECK(Bignum::LessEqual(bignum1, bignum2));
1118 CHECK(!Bignum::LessEqual(bignum2, bignum1));
1119 CHECK(Bignum::Less(bignum1, bignum2));
1120 CHECK(!Bignum::Less(bignum2, bignum1));
1124 CHECK_EQ(0, Bignum::Compare(bignum1, bignum2));
1128 CHECK_EQ(-1, Bignum::Compare(bignum1, bignum2));
1129 CHECK_EQ(+1, Bignum::Compare(bignum2, bignum1));
1135 CHECK_EQ(0, Bignum::Compare(bignum1, bignum2));
1141 CHECK_EQ(-1, Bignum::Compare(bignum1, bignum2));
1142 CHECK_EQ(+1, Bignum::Compare(bignum2, bignum1));
1147 CHECK_EQ(0, Bignum::Compare(bignum1, bignum2));
1148 CHECK_EQ(0, Bignum::Compare(bignum2, bignum1));
1153 CHECK_EQ(-1, Bignum::Compare(bignum1, bignum2));
1154 CHECK_EQ(+1, Bignum::Compare(bignum2, bignum1));
1160 CHECK_EQ(-1, Bignum::Compare(bignum1, bignum2));
1161 CHECK_EQ(+1, Bignum::Compare(bignum2, bignum1));
1166 CHECK_EQ(-1, Bignum::Compare(bignum1, bignum2));
1167 CHECK_EQ(+1, Bignum::Compare(bignum2, bignum1));
1173 CHECK_EQ(-1, Bignum::Compare(bignum1, bignum2));
1174 CHECK_EQ(+1, Bignum::Compare(bignum2, bignum1));
1180 CHECK_EQ(+1, Bignum::Compare(bignum1, bignum2));
1181 CHECK_EQ(-1, Bignum::Compare(bignum2, bignum1));
1187 CHECK_EQ(-1, Bignum::Compare(bignum1, bignum2));
1188 CHECK_EQ(+1, Bignum::Compare(bignum2, bignum1));
1193 CHECK_EQ(0, Bignum::Compare(bignum1, bignum2));
1194 CHECK_EQ(0, Bignum::Compare(bignum2, bignum1));
1199 CHECK_EQ(+1, Bignum::Compare(bignum1, bignum2));
1200 CHECK_EQ(-1, Bignum::Compare(bignum2, bignum1));
1205 CHECK_EQ(-1, Bignum::Compare(bignum1, bignum2));
1206 CHECK_EQ(+1, Bignum::Compare(bignum2, bignum1));
1211 Bignum a;
1212 Bignum b;
1213 Bignum c;
1217 CHECK_EQ(0, Bignum::PlusCompare(a, b, c));
1218 CHECK(Bignum::PlusEqual(a, b, c));
1219 CHECK(Bignum::PlusLessEqual(a, b, c));
1220 CHECK(!Bignum::PlusLess(a, b, c));
1225 CHECK_EQ(-1, Bignum::PlusCompare(a, b, c));
1226 CHECK_EQ(+1, Bignum::PlusCompare(c, b, a));
1227 CHECK(!Bignum::PlusEqual(a, b, c));
1228 CHECK(!Bignum::PlusEqual(c, b, a));
1229 CHECK(Bignum::PlusLessEqual(a, b, c));
1230 CHECK(!Bignum::PlusLessEqual(c, b, a));
1231 CHECK(Bignum::PlusLess(a, b, c));
1232 CHECK(!Bignum::PlusLess(c, b, a));
1237 CHECK_EQ(+1, Bignum::PlusCompare(a, b, c));
1242 CHECK_EQ(0, Bignum::PlusCompare(a, b, c));
1248 CHECK_EQ(0, Bignum::PlusCompare(a, b, c));
1254 CHECK_EQ(-1, Bignum::PlusCompare(a, b, c));
1260 CHECK_EQ(1, Bignum::PlusCompare(a, b, c));
1266 CHECK_EQ(1, Bignum::PlusCompare(a, b, c));
1272 CHECK_EQ(-1, Bignum::PlusCompare(a, b, c));
1280 CHECK_EQ(0, Bignum::PlusCompare(a, b, c));
1288 CHECK_EQ(-1, Bignum::PlusCompare(a, b, c));
1296 CHECK_EQ(1, Bignum::PlusCompare(a, b, c));
1304 CHECK_EQ(1, Bignum::PlusCompare(a, b, c));
1312 CHECK_EQ(-1, Bignum::PlusCompare(a, b, c));
1319 CHECK_EQ(0, Bignum::PlusCompare(a, b, c));
1326 CHECK_EQ(-1, Bignum::PlusCompare(a, b, c));
1333 CHECK_EQ(1, Bignum::PlusCompare(a, b, c));
1340 CHECK_EQ(1, Bignum::PlusCompare(a, b, c));
1347 CHECK_EQ(-1, Bignum::PlusCompare(a, b, c));
1353 CHECK_EQ(0, Bignum::PlusCompare(a, b, c));
1359 CHECK_EQ(1, Bignum::PlusCompare(a, b, c));
1365 CHECK_EQ(-1, Bignum::PlusCompare(a, b, c));
1372 CHECK_EQ(0, Bignum::PlusCompare(a, b, c));
1379 CHECK_EQ(-1, Bignum::PlusCompare(a, b, c));
1386 CHECK_EQ(-1, Bignum::PlusCompare(a, b, c));
1393 CHECK_EQ(+1, Bignum::PlusCompare(a, b, c));
1398 Bignum bignum;
1401 bignum.AssignUInt16(1);
1402 bignum.Square();
1403 CHECK(bignum.ToHexString(buffer, kBufferSize));
1406 bignum.AssignUInt16(2);
1407 bignum.Square();
1408 CHECK(bignum.ToHexString(buffer, kBufferSize));
1411 bignum.AssignUInt16(10);
1412 bignum.Square();
1413 CHECK(bignum.ToHexString(buffer, kBufferSize));
1416 AssignHexString(&bignum, "FFFFFFF");
1417 bignum.Square();
1418 CHECK(bignum.ToHexString(buffer, kBufferSize));
1421 AssignHexString(&bignum, "FFFFFFFFFFFFFF");
1422 bignum.Square();
1423 CHECK(bignum.ToHexString(buffer, kBufferSize));
1429 Bignum bignum;
1432 bignum.AssignPowerUInt16(1, 0);
1433 CHECK(bignum.ToHexString(buffer, kBufferSize));
1436 bignum.AssignPowerUInt16(1, 1);
1437 CHECK(bignum.ToHexString(buffer, kBufferSize));
1440 bignum.AssignPowerUInt16(1, 2);
1441 CHECK(bignum.ToHexString(buffer, kBufferSize));
1444 bignum.AssignPowerUInt16(2, 0);
1445 CHECK(bignum.ToHexString(buffer, kBufferSize));
1448 bignum.AssignPowerUInt16(2, 1);
1449 CHECK(bignum.ToHexString(buffer, kBufferSize));
1452 bignum.AssignPowerUInt16(2, 2);
1453 CHECK(bignum.ToHexString(buffer, kBufferSize));
1456 bignum.AssignPowerUInt16(16, 1);
1457 CHECK(bignum.ToHexString(buffer, kBufferSize));
1460 bignum.AssignPowerUInt16(16, 2);
1461 CHECK(bignum.ToHexString(buffer, kBufferSize));
1464 bignum.AssignPowerUInt16(16, 5);
1465 CHECK(bignum.ToHexString(buffer, kBufferSize));
1468 bignum.AssignPowerUInt16(16, 8);
1469 CHECK(bignum.ToHexString(buffer, kBufferSize));
1472 bignum.AssignPowerUInt16(16, 16);
1473 CHECK(bignum.ToHexString(buffer, kBufferSize));
1476 bignum.AssignPowerUInt16(16, 30);
1477 CHECK(bignum.ToHexString(buffer, kBufferSize));
1480 bignum.AssignPowerUInt16(10, 0);
1481 CHECK(bignum.ToHexString(buffer, kBufferSize));
1484 bignum.AssignPowerUInt16(10, 1);
1485 CHECK(bignum.ToHexString(buffer, kBufferSize));
1488 bignum.AssignPowerUInt16(10, 2);
1489 CHECK(bignum.ToHexString(buffer, kBufferSize));
1492 bignum.AssignPowerUInt16(10, 5);
1493 CHECK(bignum.ToHexString(buffer, kBufferSize));
1496 bignum.AssignPowerUInt16(10, 8);
1497 CHECK(bignum.ToHexString(buffer, kBufferSize));
1500 bignum.AssignPowerUInt16(10, 16);
1501 CHECK(bignum.ToHexString(buffer, kBufferSize));
1504 bignum.AssignPowerUInt16(10, 30);
1505 CHECK(bignum.ToHexString(buffer, kBufferSize));
1508 bignum.AssignPowerUInt16(10, 31);
1509 CHECK(bignum.ToHexString(buffer, kBufferSize));
1512 bignum.AssignPowerUInt16(2, 0);
1513 CHECK(bignum.ToHexString(buffer, kBufferSize));
1516 bignum.AssignPowerUInt16(2, 100);
1517 CHECK(bignum.ToHexString(buffer, kBufferSize));
1520 bignum.AssignPowerUInt16(17, 0);
1521 CHECK(bignum.ToHexString(buffer, kBufferSize));
1524 bignum.AssignPowerUInt16(17, 99);
1525 CHECK(bignum.ToHexString(buffer, kBufferSize));
1531 bignum.AssignPowerUInt16(0xFFFF, 99);
1532 CHECK(bignum.ToHexString(buffer, kBufferSize));