cryptocol/number/
macros_for_types.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
// Copyright 2023, 2024 PARK Youngho.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed
// except according to those terms.

// #![warn(missing_docs)]
// #![warn(rustdoc::missing_doc_code_examples)]
#![allow(non_camel_case_types)]
// #![allow(missing_docs)]
// #![allow(rustdoc::missing_doc_code_examples)]

//! The module that contains macros for defining big unsigned integer data types. 

/// The macro that defines the types `U256`, `U512`, `U1024`, `U2048`, `U3072`,
/// `U4096`, `U5120`, `U6144`, `U7168`, `U8192`, and `U16384`. 
/// 
/// The types `U256`, `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`,
/// `U6144`, `U7168`, `U8192`, and `U16384` are 256-bit, 512-bit, 1024-bit,
/// U2048-bit, 3072-bit, 4096-bit, 5120-bit, 6144-bit, 7168-bit, 8192-bit,
/// and 16384-bit big unsigned integer types, respectively.
/// They are defined based on `u8`, `u16`, `u32`, `u64` and `u128` according
/// to the given parameter.
/// 
/// They are defined based on `u8`, `u16`, `u32`, `u64` and `u128` according
/// to the given parameter.
/// 
/// So, if you give `u128` as a parameter, it will define `U256`, `U512`,
/// `U1024`, `U2048`, `U3072`, `U4096`, `U5120`, `U6144`, `U7168`, `U8192`,
/// and `U16384`, based on `u128`. That is, U256, U256_, U1024, and U1024 will
/// be defined to be `BigUInt<u128, 2>` and `BigUInt<u128, 8>`, respectively,
/// for example.
/// 
/// Furthermore, `UU32`, `UU64`, `UU128`, `UU256`, `UU384`, `UU512`, `UU640`,
/// `UU768`, `UU896`, `UU1024`, and `UU2048` will be also defined to be `U256`,
/// `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`, `U6144`, `U7168`,
/// `U8192`, and `U16384`, respectively. `UU32` is 32-byte big unsigned integer
/// type, and `UU64` is 64-byte big unsigned integer type, and `UU128` is
/// 128-byte big unsigned integer type, and so on.
/// That is, `UU32` is a synonym of `U256`, and `UU64` is a synonym of `U512`,
/// and so on.
/// 
/// If you define big unsigned integer types with `define_utypes_with!(u128)`,
/// `U1024` and `UU128` will be `BigUInt<u128, 8>`.
/// If you define big unsigned integer types with `define_utypes_with!(u64)`,
/// `U1024` and `UU128` will be `BigUInt<u64, 16>`.
/// If you define big unsigned integer types with `define_utypes_with!(u32)`,
/// `U1024` and `UU128` will be `BigUInt<u32, 32>`.
/// They are all the same sized, but their insides or structures are all
/// different from one another.
/// 
/// According to the performance test carried out on Samsung Laptop with Intel
/// I5 core and 32 GB RAM under Linux Mint 21.1 (Vera) on the date 5th of July,
/// 2023, the big unsigned integer type based on u128 showed the best
/// performance. So, you are highly recommended to use the big unsigned integer
/// types based on u128.
/// 
/// However, the performance results may be different under different conditions
/// such as on other machines, under other operating systems, etc. It means that
/// the big unsigned integer types based on u128 may or may not show the best
/// performance under certain conditions. You can test the performance by
/// yourself and find the best parameter for your system. The performance test
/// code used for test is as follows:
///
/// # Performance Test Code
/// ```
/// use std::time::SystemTime;
/// use std::fmt::{ Display, Debug };
/// use std::ops::*;
/// use cryptocol::number::*;
/// 
/// fn main()
/// {
///     let num_txt = "1111111111_1111111111_1111111111_1111111111_1111111111_1111111111_1111111111_1111111111_1111111111_1111111111_1111111111_1111111111_1111111111_1111111111_1111111111_1111111111_";
///     let a_128 = U1024_with_u128::from_string(num_txt).unwrap();
///     let a_64 = U1024_with_u64::from_string(num_txt).unwrap();
///     let a_32 = U1024_with_u32::from_string(num_txt).unwrap();
///     let a_16 = U1024_with_u16::from_string(num_txt).unwrap();
///     let a_8 = U1024_with_u8::from_string(num_txt).unwrap();
/// 
///     calcAdd(&a_128);
///     calcAdd(&a_64);
///     calcAdd(&a_32);
///     calcAdd(&a_16);
///     calcAdd(&a_8);
///
///     calcMul(&a_128);
///     calcMul(&a_64);
///     calcMul(&a_32);
///     calcMul(&a_16);
///     calcMul(&a_8);
/// }
/// 
/// fn calcAdd<T, const N: usize>(a: &BigUInt<T, N>)
/// where T: SmallUInt + Display + Debug + ToString
///         + Add<Output=T> + AddAssign + Sub<Output=T> + SubAssign
///         + Mul<Output=T> + MulAssign + Div<Output=T> + DivAssign
///         + Shl<Output=T> + ShlAssign + Shr<Output=T> + ShrAssign
///         + BitAnd<Output=T> + BitAndAssign + BitOr<Output=T> + BitOrAssign
///         + BitXor<Output=T> + BitXorAssign + Not<Output=T>
///         + PartialEq + PartialOrd
/// {
///     let mut sum = BigUInt::<T, N>::zero();
///     let now = SystemTime::now();
///     for _ in 0..1000
///     {
///         sum += *a;
///     }
///     let elapsed = now.elapsed().unwrap();
///     println!("{}-bit addition operation takes\t{}", T::size_in_bits(), elapsed.as_nanos());
/// }
///
/// fn calcMul<T, const N: usize>(a: &BigUInt<T, N>)
/// where T: SmallUInt + Display + Debug + ToString
///         + Add<Output=T> + AddAssign + Sub<Output=T> + SubAssign
///         + Mul<Output=T> + MulAssign + Div<Output=T> + DivAssign
///         + Shl<Output=T> + ShlAssign + Shr<Output=T> + ShrAssign
///         + BitAnd<Output=T> + BitAndAssign + BitOr<Output=T> + BitOrAssign
///         + BitXor<Output=T> + BitXorAssign + Not<Output=T>
///         + PartialEq + PartialOrd
/// {
///     let mut sum = BigUInt::<T, N>::one();
///     let now = SystemTime::now();
///     for _ in 0..1000
///     {
///         sum *= *a;
///     }
///     let elapsed = now.elapsed().unwrap();
///     println!("{}-bit multiplication operation takes\t{}", T::size_in_bits(), elapsed.as_nanos());
/// }
/// ```
/// The following examples show how to use the macro `define_utypes_with!(...)`.
/// 
/// # Examples
/// ```
/// use cryptocol::define_utypes_with;
/// define_utypes_with!(u128);
/// let a = U256::from_string("1234567_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890").unwrap();
/// let b = a << 1;
/// println!("b = {}", b);
/// assert_eq!(b, UU32::from_string("24691342469135780246913578024691357802469135780246913578024691357802469135780").unwrap());
/// ```
/// Here, `u128` is used as a base type in the macro `define_utypes_with!(u128)`.
/// So, `U256` and `UU32` are both `BigUInt<u128, 2>`, but you can choose a
/// different parameter such as `u64`. Then, `U256` and `UU32` are both
/// `BigUInt<u64, 4>`.
/// 
/// The following example shows the different case that `u64`
/// is used as a base type in the macro `define_utypes_with!(u64)`.
/// ```
/// use cryptocol::define_utypes_with;
/// define_utypes_with!(u64);
/// let a = U256::from_string("1234567_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890").unwrap();
/// let b = a << 1;
/// println!("b = {}", b);
/// assert_eq!(b, UU32::from_string("24691342469135780246913578024691357802469135780246913578024691357802469135780").unwrap());
/// ```
#[macro_export]
macro_rules! define_utypes_with
{
    (u128) =>
        {
            use cryptocol::define_utypes_with_u128;
            define_utypes_with_u128!();
        };
    (u64) =>
        {
            use cryptocol::define_utypes_with_u64;
            define_utypes_with_u64!();
        };
    (u32) =>
        {
            use cryptocol::define_utypes_with_u32;
            define_utypes_with_u32!();
        };
    (u16) =>
        {
            use cryptocol::define_utypes_with_u16;
            define_utypes_with_u16!();
        };
    (u8) =>
        {
            use cryptocol::define_utypes_with_u8;
            define_utypes_with_u8!();
        };
}


/// The macro that defines the types `U256`, `U512`, `U1024`, `U2048`,
/// `U3072`, `U4096`, `U5120`, `U6144`, `U7168`, `U8192`, and `U16384`
/// __based on `u128`__.
/// 
/// The types `U256`, `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`,
/// `U6144`, `U7168`, `U8192`, and `U16384` are 256-bit, 512-bit, 1024-bit,
/// 2048-bit, 3072-bit, 4096-bit, 5120-bit, 6144-bit, 7168-bit, 8192-bit,
/// and 16384-bit big unsigned integer types, respectively.
/// They are all defined __based on `u128`__.
/// 
/// So, it will define `U256`, `U512`, `U1024`, `U2048`, `U3072`, `U4096`,
/// `U5120`, `U6144`, `U7168`, `U8192`, and  `U16384` __based on `u128`__.
/// That is, `U256` and `U1024` will be defined to be `BigUInt<u128, 2>`
/// and `BigUInt<u128, 8>`, respectively, for example.
/// 
/// Furthermore, `UU32`, `UU64`, `UU128`, `UU256`, `UU384`, `UU512`, `UU640`,
/// `UU768`, `UU896`, `UU1024`, and `UU2048` will be also defined to be `U256`,
/// `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`, `U6144`, `U7168`,
/// `U8192`, and `U16384`, respectively.
/// `UU32` is 32-byte big unsigned integer type, and
/// `UU64` is 64-byte big unsigned integer type, and
/// `UU128` is 128-byte big unsigned integer type and so on.
/// That is, `UU32` is a synonym of `U256`, and
/// `UU64` is a synonym of `U512`, and so on.
/// 
/// The following examples show how to use the macro `define_utypes_with_u128!()`.
/// 
/// # Example
/// ```
/// use cryptocol::define_utypes_with_u128;
/// define_utypes_with_u128!();
/// let a = U256::from_string("1234567_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890").unwrap();
/// let b = a << 1;
/// println!("b = {}", b);
/// assert_eq!(b, UU32::from_string("24691342469135780246913578024691357802469135780246913578024691357802469135780").unwrap());
/// ```
/// Here, `u128` is used as a base type in the macro `define_utypes_with_u128!()`.
/// So, `U256` and `UU32` are both `BigUInt<u128, 2>`. This macro
/// `define_utypes_with_u128!()` is virtually the same as `define_utypes_with!(u128)`.
/// Actually, this macro `define_utypes_with_u128!()` is used in the macro
/// `define_utypes_with!(...)`.
#[macro_export]
macro_rules! define_utypes_with_u128
{
    () =>
    {
        use cryptocol::number::{ U256_with_u128, U512_with_u128, U1024_with_u128, U2048_with_u128,
                                U3072_with_u128, U4096_with_u128, U5120_with_u128, U6144_with_u128,
                                U7168_with_u128, U8192_with_u128, U16384_with_u128 };

        /// 256-bit unsigned integer, Synonym of `U256_with_u128`
        pub type U256 = U256_with_u128;

        /// 512-bit unsigned integer for 128-bit machines, Synonym of `U512_with_u128`
        pub type U512 = U512_with_u128;

        /// 1024-bit unsigned integer for 128-bit machines, Synonym of `U1024_with_u128`
        pub type U1024 = U1024_with_u128;

        /// 2048-bit unsigned integer for 128-bit machines, Synonym of `U2048_with_u128`
        pub type U2048 = U2048_with_u128;

        /// 3072-bit unsigned integer for 128-bit machines, Synonym of `U3072_with_u128`
        pub type U3072 = U3072_with_u128;

        /// 4096-bit unsigned integer for 128-bit machines, Synonym of `U4096_with_u128`
        pub type U4096 = U4096_with_u128;

        /// 5120-bit unsigned integer for 128-bit machines, Synonym of `U5120_with_u128`
        pub type U5120 = U5120_with_u128;

        /// 6144-bit unsigned integer for 128-bit machines, Synonym of `U6144_with_u128`
        pub type U6144 = U6144_with_u128;

        /// 7168-bit unsigned integer for 128-bit machines, Synonym of `U7168_with_u128`
        pub type U7168 = U7168_with_u128;

        /// 8192-bit unsigned integer for 128-bit machines, Synonym of `U8192_with_u128`
        pub type U8192 = U8192_with_u128;

        /// 16384-bit unsigned integer for 128-bit machines, Synonym of `U16384_with_u128`
        pub type U16384 = U16384_with_u128;

        /// 32-byte unsigned integer, Synonym of `U256`
        pub type UU32 = U256;

        /// 64-byte unsigned integer, Synonym of `U512`
        pub type UU64 = U512;

        /// 128-byte unsigned integer, Synonym of `U1024`
        pub type UU128 = U1024;

        /// 256-byte unsigned integer, Synonym of `U2048`
        pub type UU256 = U2048;

        /// 384-byte unsigned integer, Synonym of `U3072`
        pub type UU384 = U3072;

        /// 512-byte unsigned integer, Synonym of `U4096`
        pub type UU512 = U4096;

        /// 640-byte unsigned integer, Synonym of `U5120`
        pub type UU640 = U5120;

        /// 760-byte unsigned integer, Synonym of `U6144`
        pub type UU768 = U6144;

        /// 896-byte unsigned integer, Synonym of `U7168`
        pub type UU896 = U7168;

        /// 1024-byte unsigned integer, Synonym of `U8192`
        pub type UU1024 = U8192;

        /// 2048-byte unsigned integer, Synonym of `U16384`
        pub type UU2048 = U16384;
    }
}


/// The macro that defines the types `U256`, `U512`, `U1024`, `U2048`,
/// `U3072`, `U4096`, `U5120`, `U6144`, `U7168`, `U8192`, and `U16384`
/// __based on `u64`__. 
/// 
/// The types `U256`, `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`,
/// `U6144`, `U7168`, `U8192`, and `U16384` are 256-bit, 512-bit, 1024-bit,
/// 2048-bit, 3072-bit, 4096-bit, 5120-bit, 6144-bit, 7168-bit, 8192-bit,
/// and 16384-bit big unsigned integer types, respectively.
/// They are all defined __based on `u64`__.
/// 
/// So, it will define `U256`, `U512`, `U1024`, `U2048`, `U3072`, `U4096`,
/// `U5120`, `U6144`, `U7168`, `U8192`, and  `U16384` __based on `u64`__.
/// That is, `U256` and `U1024` will be defined to be `BigUInt<u64, 4>`
/// and `BigUInt<u64, 16>`, respectively, for example.
/// 
/// Furthermore, `UU32`, `UU64`, `UU128`, `UU256`, `UU384`, `UU512`, `UU640`,
/// `UU768`, `UU896`, `UU1024`, and `UU2048` will be also defined to be `U256`,
/// `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`, `U6144`, `U7168`,
/// `U8192`, and `U16384`, respectively.
/// `UU32` is 32-byte big unsigned integer type, and
/// `UU64` is 64-byte big unsigned integer type, and
/// `UU128` is 128-byte big unsigned integer type and so on.
/// That is, `UU32` is a synonym of `U256`, and
/// `UU64` is a synonym of `U512`, and so on.
/// 
/// The following examples show how to use the macro `define_utypes_with_u64!()`.
/// 
/// # Example
/// ```
/// use cryptocol::define_utypes_with_u64;
/// define_utypes_with_u64!();
/// let a = U256::from_string("1234567_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890").unwrap();
/// let b = a << 1;
/// println!("b = {}", b);
/// assert_eq!(b, UU32::from_string("24691342469135780246913578024691357802469135780246913578024691357802469135780").unwrap());
/// ```
/// Here, `u64` is used as a base type in the macro `define_utypes_with_u64!()`.
/// So, `U256` and `UU32` are both `BigUInt<u64, 4>`. This macro
/// `define_utypes_with_u64!()` is virtually the same as `define_utypes_with!(u64)`.
/// Actually, this macro `define_utypes_with_u64!()` is used in the macro
/// `define_utypes_with!(...)`.
#[macro_export]
macro_rules! define_utypes_with_u64
{
    () =>
    {
        use cryptocol::number::{ U256_with_u64, U512_with_u64, U1024_with_u64, U2048_with_u64,
                                U3072_with_u64, U4096_with_u64, U5120_with_u64, U6144_with_u64,
                                U7168_with_u64, U8192_with_u64, U16384_with_u64 };

        /// 256-bit unsigned integer for 64-bit machines, Synonym of `U256_with_u64`
        pub type U256 = U256_with_u64;

        /// 512-bit unsigned integer for 64-bit machines, Synonym of `U512_with_u64`
        pub type U512 = U512_with_u64;

        /// 1024-bit unsigned integer for 64-bit machines, Synonym of `U1024_with_u64`
        pub type U1024 = U1024_with_u64;

        /// 2048-bit unsigned integer for 64-bit machines, Synonym of `U2048_with_u64`
        pub type U2048 = U2048_with_u64;

        /// 3072-bit unsigned integer for 64-bit machines, Synonym of `U3072_with_u64`
        pub type U3072 = U3072_with_u64;

        /// 4096-bit unsigned integer for 64-bit machines, Synonym of `U4096_with_u64`
        pub type U4096 = U4096_with_u64;

        /// 5120-bit unsigned integer for 64-bit machines, Synonym of `U5120_with_u64`
        pub type U5120 = U5120_with_u64;

        /// 6144-bit unsigned integer for 64-bit machines, Synonym of `U6144_with_u64`
        pub type U6144 = U6144_with_u64;

        /// 7168-bit unsigned integer for 64-bit machines, Synonym of `U7168_with_u64`
        pub type U7168 = U7168_with_u64;

        /// 8192-bit unsigned integer for 64-bit machines, Synonym of `U8192_with_u64`
        pub type U8192 = U8192_with_u64;

        /// 16384-bit unsigned integer for 64-bit machines, Synonym of `U16384_with_u64`
        pub type U16384 = U16384_with_u64;

        /// 32-byte unsigned integer, Synonym of `U256`
        pub type UU32 = U256;

        /// 64-byte unsigned integer, Synonym of `U512`
        pub type UU64 = U512;

        /// 128-byte unsigned integer, Synonym of `U1024`
        pub type UU128 = U1024;

        /// 256-byte unsigned integer, Synonym of `U2048`
        pub type UU256 = U2048;

        /// 384-byte unsigned integer, Synonym of `U3072`
        pub type UU384 = U3072;

        /// 512-byte unsigned integer, Synonym of `U4096`
        pub type UU512 = U4096;

        /// 640-byte unsigned integer, Synonym of `U5120`
        pub type UU640 = U5120;

        /// 760-byte unsigned integer, Synonym of `U6144`
        pub type UU768 = U6144;

        /// 896-byte unsigned integer, Synonym of `U7168`
        pub type UU896 = U7168;

        /// 1024-byte unsigned integer, Synonym of `U8192`
        pub type UU1024 = U8192;

        /// 2048-byte unsigned integer, Synonym of `U16384`
        pub type UU2048 = U16384;
    };
}


/// The macro that defines the types `U256`, `U512`, `U1024`, `U2048`,
/// `U3072`, `U4096`, `U5120`, `U6144`, `U7168`, `U8192`, and `U16384`
/// __based on `u32`__. 
/// 
/// The types `U256`, `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`,
/// `U6144`, `U7168`, `U8192`, and `U16384` are 256-bit, 512-bit, 1024-bit,
/// 2048-bit, 3072-bit, 4096-bit, 5120-bit, 6144-bit, 7168-bit, 8192-bit,
/// and 16384-bit big unsigned integer types, respectively.
/// They are all defined __based on `u32`__.
/// 
/// So, it will define `U256`, `U256_`, `U512`, `U512_`, `U1024`, `U1024_`,
/// `U2048`, `U2048_`, `U3072`, `U3072_`,`U4096`, `U4096_`, `U5120`, `U5120_`,
/// `U6144`, `U6144_`, `U7168`, `U7168_`, `U8192`, `U8192_`,
/// `U16384`, and `U16384_` __based on `u32`__.
/// That is, `U256` and `U1024` will be defined to be `BigUInt<u32, 8>`
/// and `BigUInt<<u32, 32>`, respectively, for example.
/// 
/// Furthermore, `UU32`, `UU64`, `UU128`, `UU256`, `UU384`, `UU512`, `UU640`,
/// `UU768`, `UU896`, `UU1024`, and `UU2048` will be also defined to be `U256`,
/// `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`, `U6144`, `U7168`,
/// `U8192`, and `U16384`, respectively.
/// `UU32` is 32-byte big unsigned integer type, and
/// `UU64` is 64-byte big unsigned integer type, and
/// `UU128` is 128-byte big unsigned integer type and so on.
/// That is, `UU32` is a synonym of `U256`, and
/// `UU64` is a synonym of `U512`, and so on.
/// 
/// The following examples show how to use the macro `define_utypes_with_u32!()`.
/// 
/// # Example
/// ```
/// use cryptocol::define_utypes_with_u32;
/// define_utypes_with_u32!();
/// let a = U256::from_string("1234567_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890").unwrap();
/// let b = a << 1;
/// println!("b = {}", b);
/// assert_eq!(b, UU32::from_string("24691342469135780246913578024691357802469135780246913578024691357802469135780").unwrap());
/// ```
/// Here, `u16` is used as a base type in the macro `define_utypes_with_u32!()`.
/// So, `U256` and `UU32` are both `BigUInt<u32, 8>`. This macro
/// `define_utypes_with_u32!()` is virtually the same as `define_utypes_with!(u32)`.
/// Actually, this macro `define_utypes_with_u32!()` is used in the macro
/// `define_utypes_with!(...)`.
#[macro_export]
macro_rules! define_utypes_with_u32
{
    () =>
    {
        use cryptocol::number::{ U256_with_u32, U512_with_u32, U1024_with_u32, U2048_with_u32,
                                U3072_with_u32, U4096_with_u32, U5120_with_u32, U6144_with_u32,
                                U7168_with_u32, U8192_with_u32, U16384_with_u32 };

        /// 256-bit unsigned integer for 32-bit machines, Synonym of `U256_with_u32`
        pub type U256 = U256_with_u32;
            
        /// 512-bit unsigned integer for 32-bit machines, Synonym of `U512_with_u32`
        pub type U512 = U512_with_u32;

        /// 1024-bit unsigned integer for 32-bit machines, Synonym of `U1024_with_u32`
        pub type U1024 = U1024_with_u32;

        /// 2048-bit unsigned integer for 32-bit machines, Synonym of `U2048_with_u32`
        pub type U2048 = U2048_with_u32;

        /// 3072-bit unsigned integer for 32-bit machines, Synonym of `U3072_with_u32`
        pub type U3072 = U3072_with_u32;

        /// 4096-bit unsigned integer for 32-bit machines, Synonym of `U4096_with_u32`
        pub type U4096 = U4096_with_u32;

        /// 5120-bit unsigned integer for 32-bit machines, Synonym of `U5120_with_u32`
        pub type U5120 = U5120_with_u32;

        /// 6144-bit unsigned integer for 32-bit machines, Synonym of `U6144_with_u32`
        pub type U6144 = U6144_with_u32;

        /// 7168-bit unsigned integer for 32-bit machines, Synonym of `U7168_with_u32`
        pub type U7168 = U7168_with_u32;

        /// 8192-bit unsigned integer for 32-bit machines, Synonym of `U8192_with_u32`
        pub type U8192 = U8192_with_u32;

        /// 16384-bit unsigned integer for 32-bit machines, Synonym of `U16384_with_u32`
        pub type U16384 = U16384_with_u32;

        /// 32-byte unsigned integer, Synonym of `U256`
        pub type UU32 = U256;

        /// 64-byte unsigned integer, Synonym of `U512`
        pub type UU64 = U512;

        /// 128-byte unsigned integer, Synonym of `U1024`
        pub type UU128 = U1024;

        /// 256-byte unsigned integer, Synonym of `U2048`
        pub type UU256 = U2048;

        /// 384-byte unsigned integer, Synonym of `U3072`
        pub type UU384 = U3072;

        /// 512-byte unsigned integer, Synonym of `U4096`
        pub type UU512 = U4096;

        /// 640-byte unsigned integer, Synonym of `U5120`
        pub type UU640 = U5120;

        /// 760-byte unsigned integer, Synonym of `U6144`
        pub type UU768 = U6144;

        /// 896-byte unsigned integer, Synonym of `U7168`
        pub type UU896 = U7168;

        /// 1024-byte unsigned integer, Synonym of `U8192`
        pub type UU1024 = U8192;

        /// 2048-byte unsigned integer, Synonym of `U16384`
        pub type UU2048 = U16384;
    };
}


/// The macro that defines the types `U256`, `U512`, `U1024`, `U2048`,
/// `U3072`, `U4096`, `U5120`, `U6144`, `U7168`, `U8192`, and `U16384`
/// __based on `u16`__. 
/// 
/// The types `U256`, `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`,
/// `U6144`, `U7168`, `U8192`, and `U16384` are 256-bit, 512-bit, 1024-bit,
/// 2048-bit, 3072-bit, 4096-bit, 5120-bit, 6144-bit, 7168-bit, 8192-bit,
/// and 16384-bit big unsigned integer types, respectively.
/// They are all defined __based on `u16`__.
/// 
/// So, it will define `U256`, `U512`, `U1024`, `U2048`, `U3072`, `U4096`,
/// `U5120`, `U6144`, `U7168`, `U8192`, and  `U16384` __based on `u16`__.
/// That is, `U256` and `U1024` will be defined to be `BigUInt<u16, 16>`
/// and `BigUInt<u16, 64>`, respectively, for example.
/// 
/// Furthermore, `UU32`, `UU64`, `UU128`, `UU256`, `UU384`, `UU512`, `UU640`,
/// `UU768`, `UU896`, `UU1024`, and `UU2048` will be also defined to be `U256`,
/// `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`, `U6144`, `U7168`,
/// `U8192`, and `U16384`, respectively.
/// `UU32` is 32-byte big unsigned integer type, and
/// `UU64` is 64-byte big unsigned integer type, and
/// `UU128` is 128-byte big unsigned integer type and so on.
/// That is, `UU32` is a synonym of `U256`, and
/// `UU64` is a synonym of `U512`, and so on.
/// 
/// The following examples show how to use the macro `define_utypes_with_u16!()`.
/// 
/// # Example
/// ```
/// use cryptocol::define_utypes_with_u16;
/// define_utypes_with_u16!();
/// let a = U256::from_string("1234567_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890").unwrap();
/// let b = a << 1;
/// println!("b = {}", b);
/// assert_eq!(b, UU32::from_string("24691342469135780246913578024691357802469135780246913578024691357802469135780").unwrap());
/// ```
/// Here, `u16` is used as a base type in the macro `define_utypes_with_u16!()`.
/// So, `U256` and `UU32` are both `BigUInt<u16, 16>`. This macro
/// `define_utypes_with_u16!()` is virtually the same as `define_utypes_with!(u16)`.
/// Actually, this macro `define_utypes_with_u16!()` is used in the macro
/// `define_utypes_with!(...)`.
#[macro_export]
macro_rules! define_utypes_with_u16
{
    () =>
    {
        use cryptocol::number::{ U256_with_u16, U512_with_u16, U1024_with_u16, U2048_with_u16,
                                U3072_with_u16, U4096_with_u16, U5120_with_u16, U6144_with_u16,
                                U7168_with_u16, U8192_with_u16, U16384_with_u16 };
                                
        /// 256-bit unsigned integer for 16-bit machines, Synonym of `U256_with_u16`
        pub type U256 = U256_with_u16;

        /// 512-bit unsigned integer for 16-bit machines, Synonym of `U512_with_u16`
        pub type U512 = U512_with_u16;

        /// 1024-bit unsigned integer for 16-bit machines, Synonym of `U1024_with_u16`
        pub type U1024 = U1024_with_u16;

        /// 2048-bit unsigned integer for 16-bit machines, Synonym of `U2048_with_u16`
        pub type U2048 = U2048_with_u16;

        /// 3072-bit unsigned integer for 16-bit machines, Synonym of `U3072_with_u16`
        pub type U3072 = U3072_with_u16;

        /// 4096-bit unsigned integer for 16-bit machines, Synonym of `U4096_with_u16`
        pub type U4096 = U4096_with_u16;

        /// 5120-bit unsigned integer for 16-bit machines, Synonym of `U5120_with_u16`
        pub type U5120 = U5120_with_u16;

        /// 6144-bit unsigned integer for 16-bit machines, Synonym of `U6144_with_u16`
        pub type U6144 = U6144_with_u16;

        /// 7168-bit unsigned integer for 16-bit machines, Synonym of `U7168_with_u16`
        pub type U7168 = U7168_with_u16;

        /// 8192-bit unsigned integer for 16-bit machines, Synonym of `U8192_with_u16`
        pub type U8192 = U8192_with_u16;

        /// 16384-bit unsigned integer for 16-bit machines, Synonym of `U16384_with_u16`
        pub type U16384 = U16384_with_u16;

        /// 32-byte unsigned integer, Synonym of `U256`
        pub type UU32 = U256;

        /// 64-byte unsigned integer, Synonym of `U512`
        pub type UU64 = U512;

        /// 128-byte unsigned integer, Synonym of `U1024`
        pub type UU128 = U1024;

        /// 256-byte unsigned integer, Synonym of `U2048`
        pub type UU256 = U2048;

        /// 384-byte unsigned integer, Synonym of `U3072`
        pub type UU384 = U3072;

        /// 512-byte unsigned integer, Synonym of `U4096`
        pub type UU512 = U4096;

        /// 640-byte unsigned integer, Synonym of `U5120`
        pub type UU640 = U5120;

        /// 760-byte unsigned integer, Synonym of `U6144`
        pub type UU768 = U6144;

        /// 896-byte unsigned integer, Synonym of `U7168`
        pub type UU896 = U7168;

        /// 1024-byte unsigned integer, Synonym of `U8192`
        pub type UU1024 = U8192;

        /// 2048-byte unsigned integer, Synonym of `U16384`
        pub type UU2048 = U16384;
    };
}


/// The macro that defines the types `U256`, `U512`, `U1024`, `U2048`,
/// `U3072`, `U4096`, `U5120`, `U6144`, `U7168`, `U8192`, and `U16384`
/// __based on `u8`__.
/// 
/// The types `U256`, `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`,
/// `U6144`, `U7168`, `U8192`, and `U16384` are 256-bit, 512-bit, 1024-bit,
/// 2048-bit, 3072-bit, 4096-bit, 5120-bit, 6144-bit, 7168-bit, 8192-bit,
/// and 16384-bit big unsigned integer types, respectively.
/// They are all defined __based on `u8`__.
/// 
/// So, it will define `U256`, `U512`, `U1024`, `U2048`, `U3072`, `U4096`,
/// `U5120`, `U6144`, `U7168`, `U8192`, and  `U16384` __based on `u8`__.
/// That is, `U256` and `U1024` will be defined to be `BigUInt<u8, 32>`
/// and `BigUInt<u8, 128>`, respectively, for example.
/// 
/// Furthermore, `UU32`, `UU64`, `UU128`, `UU256`, `UU384`, `UU512`, `UU640`,
/// `UU768`, `UU896`, `UU1024`, and `UU2048` will be also defined to be `U256`,
/// `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`, `U6144`, `U7168`,
/// `U8192`, and `U16384`, respectively.
/// `UU32` is 32-byte big unsigned integer type, and
/// `UU64` is 64-byte big unsigned integer type, and
/// `UU128` is 128-byte big unsigned integer type and so on.
/// That is, `UU32` is a synonym of `U256`, and
/// `UU64` is a synonym of `U512`, and so on.
/// 
/// The following examples show how to use the macro `define_utypes_with_u8!()`.
/// 
/// # Example
/// ```
/// use cryptocol::define_utypes_with_u8;
/// define_utypes_with_u8!();
/// let a = U256::from_string("1234567_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890_1234567890").unwrap();
/// let b = a << 1;
/// println!("b = {}", b);
/// assert_eq!(b, UU32::from_string("24691342469135780246913578024691357802469135780246913578024691357802469135780").unwrap());
/// ```
/// Here, `u8` is used as a base type in the macro `define_utypes_with_u8!()`.
/// So, `U256` and `UU32` are both `BigUInt<u8, 32>`. This macro
/// `define_utypes_with_u8!()` is virtually the same as `define_utypes_with!(u8)`.
/// Actually, this macro `define_utypes_with_u8!()` is used in the macro
/// `define_utypes_with!(...)`.
#[macro_export]
macro_rules! define_utypes_with_u8
{
    () =>
    {
        use cryptocol::number::{ U256_with_u8, U512_with_u8, U1024_with_u8, U2048_with_u8,
                                U3072_with_u8, U4096_with_u8, U5120_with_u8, U6144_with_u8,
                                U7168_with_u8, U8192_with_u8, U16384_with_u8 };

        /// 256-bit unsigned integer for 8-bit machines, Synonym of `U256_with_u8`
        pub type U256 = U256_with_u8;

        /// 512-bit unsigned integer for 8-bit machines, Synonym of `U512_with_u8`
        pub type U512 = U512_with_u8;

        /// 1024-bit unsigned integer for 8-bit machines, Synonym of `U1024_with_u8`
        pub type U1024 = U1024_with_u8;

        /// 2048-bit unsigned integer for 8-bit machines, Synonym of `U2048_with_u8`
        pub type U2048 = U2048_with_u8;

        /// 3072-bit unsigned integer for 8-bit machines, Synonym of `U3072_with_u8`
        pub type U3072 = U3072_with_u8;

        /// 4096-bit unsigned integer for 8-bit machines, Synonym of `U4096_with_u8`
        pub type U4096 = U4096_with_u8;

        /// 5120-bit unsigned integer for 8-bit machines, Synonym of `U5120_with_u8`
        pub type U5120 = U5120_with_u8;

        /// 6144-bit unsigned integer for 8-bit machines, Synonym of `U6144_with_u8`
        pub type U6144 = U6144_with_u8;

        /// 7168-bit unsigned integer for 8-bit machines, Synonym of `U7168_with_u8`
        pub type U7168 = U7168_with_u8;

        /// 8192-bit unsigned integer for 8-bit machines, Synonym of `U8192_with_u8`
        pub type U8192 = U8192_with_u8;

        /// 16384-bit unsigned integer for 8-bit machines, Synonym of `U16384_with_u8`
        pub type U16384 = U16384_with_u8;

        /// 32-byte unsigned integer, Synonym of `U256`
        pub type UU32 = U256;

        /// 64-byte unsigned integer, Synonym of `U512`
        pub type UU64 = U512;

        /// 128-byte unsigned integer, Synonym of `U1024`
        pub type UU128 = U1024;

        /// 256-byte unsigned integer, Synonym of `U2048`
        pub type UU256 = U2048;

        /// 384-byte unsigned integer, Synonym of `U3072`
        pub type UU384 = U3072;

        /// 512-byte unsigned integer, Synonym of `U4096`
        pub type UU512 = U4096;

        /// 640-byte unsigned integer, Synonym of `U5120`
        pub type UU640 = U5120;

        /// 760-byte unsigned integer, Synonym of `U6144`
        pub type UU768 = U6144;

        /// 896-byte unsigned integer, Synonym of `U7168`
        pub type UU896 = U7168;

        /// 1024-byte unsigned integer, Synonym of `U8192`
        pub type UU1024 = U8192;

        /// 2048-byte unsigned integer, Synonym of `U16384`
        pub type UU2048 = U16384;
    };
}


// /// The macro that defines the types `UU32`, `UU64`, `UU128`, `UU256`, `UU384`,
// /// `UU512`, `UU640`, `UU768`, `UU896`, `UU1024`, and `UU2048`.
// /// 
// /// In order to use this macro `define_uutypes_with_utypes!()`, the types `U256`,
// /// `U512`, `U1024`, `U2048`, `U3072`, `U4096`, `U5120`, `U6144`, `U7168`,
// /// `U8192`, and `U16384` should have been defined beforehand.
// /// 
// /// The types `UU32`, `UU64`, `UU128`, `UU256`, `UU384`, `UU512`, `UU640`, `UU768`,
// /// `UU896`, `UU1024`, and `UU2048` are 32-byte, 64-byte, 128-byte, 256-byte,
// /// 384-byte, 512-byte, 640-byte, 768-byte, 896-byte, 1024-byte, and 2048-byte
// /// big unsigned integer types, respectively.
// /// 
// /// `UU32`, `UU64`, `UU128`, `UU256`, `UU384`, `UU512`, `UU640`, `UU768`, `UU896`,
// /// `UU1024`, and `UU2048` will be defined to be `U256`, `U512`, `U1024`,
// /// `U2048`, `U3072`, `U4096`, `U5120`, `U6144`, `U7168`, `U8192`, and `U16384`,
// /// respectively. That is, `UU32` is a synonym of `U256`, `UU64` is a synonym of
// /// `U512`, and so on.
// /// 
// /// Actually, this macro `define_uutypes_with_utypes!()` is
// /// used in the macros `define_utypes_with_u8!()`, `define_utypes_with_u16!()`,
// /// `define_utypes_with_u32!()`, `define_utypes_with_u64!()`, and
// /// `define_utypes_with_u128!()` which are used in the macro 
// /// `define_utypes_with!(...)`.
// /// 
// /// You are highly recommended not use this macro `define_uutypes_with_utypes!()`
// /// unless you really need to use it in your code. Instead, use
// /// `define_utypes_with_u8!()`, `define_utypes_with_u16!()`,
// /// `define_utypes_with_u32!()`, `define_utypes_with_u64!()`,
// /// `define_utypes_with_u128!()` or `define_utypes_with!(...)` if you need.
// #[macro_export]
// macro_rules! define_uutypes_with_utypes
// {
//     () =>
//     {
//         /// 32-byte unsigned integer, Synonym of `U256`
//         pub type UU32 = U256;

//         /// 64-byte unsigned integer, Synonym of `U512`
//         pub type UU64 = U512;

//         /// 128-byte unsigned integer, Synonym of `U1024`
//         pub type UU128 = U1024;

//         /// 256-byte unsigned integer, Synonym of `U2048`
//         pub type UU256 = U2048;

//         /// 384-byte unsigned integer, Synonym of `U3072`
//         pub type UU384 = U3072;

//         /// 512-byte unsigned integer, Synonym of `U4096`
//         pub type UU512 = U4096;

//         /// 640-byte unsigned integer, Synonym of `U5120`
//         pub type UU640 = U5120;

//         /// 760-byte unsigned integer, Synonym of `U6144`
//         pub type UU768 = U6144;

//         /// 896-byte unsigned integer, Synonym of `U7168`
//         pub type UU896 = U7168;

//         /// 1024-byte unsigned integer, Synonym of `U8192`
//         pub type UU1024 = U8192;

//         /// 2048-byte unsigned integer, Synonym of `U16384`
//         pub type UU2048 = U16384;
//     };
// }