1pub type D38<const SCALE: u32> = crate::D<i128, SCALE>;
56
57impl<const SCALE: u32> Default for crate::D<i128, SCALE> {
70 #[inline]
71 fn default() -> Self {
72 Self::ZERO
73 }
74}
75
76pub type D38s0 = D38<0>;
97
98pub type D38s1 = D38<1>;
105
106pub type D38s2 = D38<2>;
112
113pub type D38s3 = D38<3>;
120
121pub type D38s4 = D38<4>;
127
128pub type D38s5 = D38<5>;
134
135pub type D38s6 = D38<6>;
142
143pub type D38s7 = D38<7>;
149
150pub type D38s8 = D38<8>;
156
157pub type D38s9 = D38<9>;
164
165pub type D38s10 = D38<10>;
171
172pub type D38s11 = D38<11>;
178
179pub type D38s12 = D38<12>;
192
193pub type D38s13 = D38<13>;
199
200pub type D38s14 = D38<14>;
206
207pub type D38s15 = D38<15>;
213
214pub type D38s16 = D38<16>;
220
221pub type D38s17 = D38<17>;
227
228pub type D38s18 = D38<18>;
235
236pub type D38s19 = D38<19>;
242
243pub type D38s20 = D38<20>;
249
250pub type D38s21 = D38<21>;
256
257pub type D38s22 = D38<22>;
263
264pub type D38s23 = D38<23>;
270
271pub type D38s24 = D38<24>;
277
278pub type D38s25 = D38<25>;
284
285pub type D38s26 = D38<26>;
291
292pub type D38s27 = D38<27>;
298
299pub type D38s28 = D38<28>;
305
306pub type D38s29 = D38<29>;
312
313pub type D38s30 = D38<30>;
319
320pub type D38s31 = D38<31>;
326
327pub type D38s32 = D38<32>;
333
334pub type D38s33 = D38<33>;
340
341pub type D38s34 = D38<34>;
347
348pub type D38s35 = D38<35>;
358
359pub type D38s36 = D38<36>;
370
371pub type D38s37 = D38<37>;
384
385pub use crate::support::error::ParseError;
388
389crate::macros::basics::decl_decimal_basics!(D38, i128, 37);
393crate::macros::display::decl_decimal_display!(D38);
394crate::macros::from_str::decl_decimal_from_str!(D38, i128);
399crate::macros::storage_formatters::decl_decimal_storage_formatters!(D38);
400crate::macros::bitwise::decl_decimal_bitwise!(D38, i128);
405crate::macros::int_methods::decl_decimal_int_methods!(D38, i128);
408crate::macros::num_traits::decl_decimal_num_traits_conversions!(D38, i128);
410crate::macros::float_bridge::decl_decimal_float_bridge!(D38, i128);
411crate::macros::conversions::decl_from_primitive!(D38, i128, i8);
412crate::macros::conversions::decl_from_primitive!(D38, i128, i16);
413crate::macros::conversions::decl_from_primitive!(D38, i128, i32);
414crate::macros::conversions::decl_from_primitive!(D38, i128, i64);
415crate::macros::conversions::decl_from_primitive!(D38, i128, u8);
416crate::macros::conversions::decl_from_primitive!(D38, i128, u16);
417crate::macros::conversions::decl_from_primitive!(D38, i128, u32);
418crate::macros::conversions::decl_from_primitive!(D38, i128, u64);
419crate::macros::conversions::decl_try_from_i128!(D38, i128);
420crate::macros::conversions::decl_try_from_u128!(D38, i128);
421crate::macros::conversions::decl_try_from_i128!(D18, i64);
422crate::macros::conversions::decl_try_from_u128!(D18, i64);
423crate::macros::conversions::decl_try_from_i128!(D9, i32);
424crate::macros::conversions::decl_try_from_u128!(D9, i32);
425crate::macros::conversions::decl_try_from_f64!(D38, i128);
426crate::macros::conversions::decl_try_from_f32!(D38, i128);
427crate::macros::conversions::decl_try_from_f64!(D18, i64);
428crate::macros::conversions::decl_try_from_f32!(D18, i64);
429crate::macros::conversions::decl_try_from_f64!(D9, i32);
430crate::macros::conversions::decl_try_from_f32!(D9, i32);
431crate::macros::conversions::decl_decimal_int_conversion_methods!(D38, i128, i64);
432crate::macros::sign::decl_decimal_sign_methods!(D38, i128);
437crate::macros::helpers::decl_decimal_helpers!(D38);
438crate::macros::rounding_methods::decl_decimal_rounding_methods!(D38);
439crate::macros::overflow::decl_decimal_overflow_variants!(@common D38, i128);
444crate::macros::arithmetic::decl_decimal_arithmetic!(@common D38, i128);
448crate::macros::num_traits::decl_decimal_num_traits_basics!(D38);
453crate::macros::transcendental_trait::decl_decimal_transcendental_impl!(D38);
454
455crate::macros::conversions::decl_decimal_int_conversion_methods!(D18, i64, i64);
482crate::macros::conversions::decl_decimal_int_conversion_methods!(D9, i32, i32);
483
484impl<const SCALE: u32> D38<SCALE> {
489 #[inline]
500 pub fn narrow(self) -> Result<D18<SCALE>, crate::support::error::ConvertError> {
501 self.try_into()
502 }
503}
504
505pub type D9<const SCALE: u32> = crate::D<i32, SCALE>;
522
523impl<const SCALE: u32> Default for crate::D<i32, SCALE> {
529 #[inline]
530 fn default() -> Self {
531 Self::ZERO
532 }
533}
534
535crate::macros::basics::decl_decimal_basics!(D9, i32, 8);
536crate::macros::arithmetic::decl_decimal_arithmetic!(D9, i32, i64);
537crate::macros::conversions::decl_from_primitive!(D9, i32, i8);
538crate::macros::conversions::decl_from_primitive!(D9, i32, i16);
539crate::macros::conversions::decl_from_primitive!(D9, i32, u8);
540crate::macros::conversions::decl_from_primitive!(D9, i32, u16);
541crate::macros::display::decl_decimal_display!(D9);
542crate::macros::overflow::decl_decimal_overflow_variants!(D9, i32, i64);
543crate::macros::num_traits::decl_decimal_num_traits_basics!(D9);
544crate::macros::sign::decl_decimal_sign_methods!(D9, i32);
545crate::macros::consts::decl_decimal_consts!(D9, i32);
546crate::macros::from_str::decl_decimal_from_str!(D9, i32);
547crate::macros::float_bridge::decl_decimal_float_bridge!(D9, i32);
548crate::macros::storage_formatters::decl_decimal_storage_formatters!(D9);
549crate::macros::strict_transcendentals::decl_strict_transcendentals_via_d38!(D9);
550crate::macros::transcendental_trait::decl_decimal_transcendental_impl!(D9);
551crate::macros::fast_transcendentals::decl_fast_transcendentals_via_f64!(D9);
552crate::macros::pow::decl_decimal_pow!(D9);
553crate::macros::rounding_methods::decl_decimal_rounding_methods!(D9);
554crate::macros::helpers::decl_decimal_helpers!(D9);
555crate::macros::bitwise::decl_decimal_bitwise!(D9, i32);
556crate::macros::int_methods::decl_decimal_int_methods!(D9, i32);
557crate::macros::num_traits::decl_decimal_num_traits_conversions!(D9, i32);
558
559pub type D9s0 = D9<0>;
561pub type D9s1 = D9<1>;
563pub type D9s2 = D9<2>;
565pub type D9s3 = D9<3>;
567pub type D9s4 = D9<4>;
569pub type D9s5 = D9<5>;
571pub type D9s6 = D9<6>;
573pub type D9s7 = D9<7>;
575pub type D9s8 = D9<8>;
580
581pub type D18<const SCALE: u32> = crate::D<i64, SCALE>;
596
597impl<const SCALE: u32> Default for crate::D<i64, SCALE> {
603 #[inline]
604 fn default() -> Self {
605 Self::ZERO
606 }
607}
608
609crate::macros::basics::decl_decimal_basics!(D18, i64, 17);
610crate::macros::arithmetic::decl_decimal_arithmetic!(D18, i64, i128);
611crate::macros::conversions::decl_from_primitive!(D18, i64, i8);
612crate::macros::conversions::decl_from_primitive!(D18, i64, i16);
613crate::macros::conversions::decl_from_primitive!(D18, i64, i32);
614crate::macros::conversions::decl_from_primitive!(D18, i64, u8);
615crate::macros::conversions::decl_from_primitive!(D18, i64, u16);
616crate::macros::conversions::decl_from_primitive!(D18, i64, u32);
617crate::macros::display::decl_decimal_display!(D18);
618crate::macros::overflow::decl_decimal_overflow_variants!(D18, i64, i128);
619crate::macros::num_traits::decl_decimal_num_traits_basics!(D18);
620crate::macros::sign::decl_decimal_sign_methods!(D18, i64);
621crate::macros::consts::decl_decimal_consts!(D18, i64);
622crate::macros::from_str::decl_decimal_from_str!(D18, i64);
623crate::macros::float_bridge::decl_decimal_float_bridge!(D18, i64);
624crate::macros::storage_formatters::decl_decimal_storage_formatters!(D18);
625crate::macros::strict_transcendentals::decl_strict_transcendentals_via_d38!(D18);
626crate::macros::transcendental_trait::decl_decimal_transcendental_impl!(D18);
627crate::macros::fast_transcendentals::decl_fast_transcendentals_via_f64!(D18);
628crate::macros::pow::decl_decimal_pow!(D18);
629crate::macros::rounding_methods::decl_decimal_rounding_methods!(D18);
630crate::macros::helpers::decl_decimal_helpers!(D18);
631crate::macros::bitwise::decl_decimal_bitwise!(D18, i64);
632crate::macros::int_methods::decl_decimal_int_methods!(D18, i64);
633crate::macros::num_traits::decl_decimal_num_traits_conversions!(D18, i64);
634
635crate::macros::conversions::decl_cross_width_widening!(D18, i64, D9, i32);
637crate::macros::conversions::decl_cross_width_widening!(D38, i128, D9, i32);
638crate::macros::conversions::decl_cross_width_widening!(D38, i128, D18, i64);
639
640crate::macros::conversions::decl_cross_width_narrowing!(D18, i64, D38, i128);
642crate::macros::conversions::decl_cross_width_narrowing!(D9, i32, D38, i128);
643crate::macros::conversions::decl_cross_width_narrowing!(D9, i32, D18, i64);
644
645impl<const SCALE: u32> D9<SCALE> {
654 #[inline]
667 #[must_use]
668 pub fn widen(self) -> D18<SCALE> {
669 self.into()
670 }
671}
672
673impl<const SCALE: u32> D18<SCALE> {
674 #[inline]
684 #[must_use]
685 pub fn widen(self) -> D38<SCALE> {
686 self.into()
687 }
688
689 #[inline]
704 pub fn narrow(self) -> Result<D9<SCALE>, crate::support::error::ConvertError> {
705 self.try_into()
706 }
707}
708
709pub type D18s0 = D18<0>;
711pub type D18s1 = D18<1>;
713pub type D18s2 = D18<2>;
715pub type D18s3 = D18<3>;
717pub type D18s4 = D18<4>;
719pub type D18s5 = D18<5>;
721pub type D18s6 = D18<6>;
723pub type D18s7 = D18<7>;
725pub type D18s8 = D18<8>;
727pub type D18s9 = D18<9>;
729pub type D18s10 = D18<10>;
731pub type D18s11 = D18<11>;
733pub type D18s12 = D18<12>;
735pub type D18s13 = D18<13>;
737pub type D18s14 = D18<14>;
739pub type D18s15 = D18<15>;
741pub type D18s16 = D18<16>;
743pub type D18s17 = D18<17>;
748
749#[cfg(any(feature = "d76", feature = "wide"))]
769pub type D76<const SCALE: u32> = crate::D<crate::wide_int::Int256, SCALE>;
770
771#[cfg(any(feature = "d76", feature = "wide"))]
778impl<const SCALE: u32> Default for crate::D<crate::wide_int::Int256, SCALE> {
779 #[inline]
780 fn default() -> Self {
781 Self::ZERO
782 }
783}
784
785#[cfg(any(feature = "d76", feature = "wide"))]
786crate::macros::full::decl_decimal_full!(
787 wide D76,
788 crate::wide_int::I256,
789 crate::wide_int::U256,
790 crate::wide_int::I512,
791 crate::wide_int::Int512,
792 crate::wide_int::Int1024,
793 crate::wide_int::Int1024,
794 wide_trig_d76,
795 75
796);
797#[cfg(any(feature = "d76", feature = "wide"))]
799crate::macros::conversions::decl_cross_width_widening!(wide D76, crate::wide_int::I256, D9, i32);
800#[cfg(any(feature = "d76", feature = "wide"))]
801crate::macros::conversions::decl_cross_width_widening!(wide D76, crate::wide_int::I256, D18, i64);
802#[cfg(any(feature = "d76", feature = "wide"))]
803crate::macros::conversions::decl_cross_width_widening!(wide D76, crate::wide_int::I256, D38, i128);
804#[cfg(any(feature = "d76", feature = "wide"))]
806crate::macros::conversions::decl_cross_width_narrowing!(wide D38, i128, D76, crate::wide_int::I256);
807#[cfg(any(feature = "d76", feature = "wide"))]
808crate::macros::conversions::decl_cross_width_narrowing!(wide D18, i64, D76, crate::wide_int::I256);
809#[cfg(any(feature = "d76", feature = "wide"))]
810crate::macros::conversions::decl_cross_width_narrowing!(wide D9, i32, D76, crate::wide_int::I256);
811
812#[cfg(any(feature = "d76", feature = "wide"))]
815impl<const SCALE: u32> D38<SCALE> {
816 #[inline]
828 #[must_use]
829 pub fn widen(self) -> D57<SCALE> {
830 self.into()
831 }
832}
833
834#[cfg(any(feature = "d76", feature = "wide"))]
835impl<const SCALE: u32> D76<SCALE> {
836 #[inline]
840 pub fn narrow(self) -> Result<D57<SCALE>, crate::support::error::ConvertError> {
841 self.try_into()
842 }
843}
844
845#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s0 = D76<0>;
847#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s1 = D76<1>;
849#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s2 = D76<2>;
851#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s3 = D76<3>;
852#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s4 = D76<4>;
853#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s6 = D76<6>;
855#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s9 = D76<9>;
856#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s12 = D76<12>;
858#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s15 = D76<15>;
859#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s18 = D76<18>;
861#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s20 = D76<20>;
862#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s24 = D76<24>;
863#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s28 = D76<28>;
864#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s32 = D76<32>;
865#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s35 = D76<35>;
867#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s38 = D76<38>;
868#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s42 = D76<42>;
869#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s48 = D76<48>;
870#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s50 = D76<50>;
872#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s56 = D76<56>;
873#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s64 = D76<64>;
874#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s70 = D76<70>;
875#[cfg(any(feature = "d76", feature = "wide"))] pub type D76s75 = D76<75>;
878
879#[cfg(any(feature = "d153", feature = "wide"))]
897pub type D153<const SCALE: u32> = crate::D<crate::wide_int::Int512, SCALE>;
898
899#[cfg(any(feature = "d153", feature = "wide"))]
906impl<const SCALE: u32> Default for crate::D<crate::wide_int::Int512, SCALE> {
907 #[inline]
908 fn default() -> Self {
909 Self::ZERO
910 }
911}
912
913#[cfg(any(feature = "d153", feature = "wide"))]
914crate::macros::full::decl_decimal_full!(
915 wide D153,
916 crate::wide_int::I512,
917 crate::wide_int::U512,
918 crate::wide_int::I1024,
919 crate::wide_int::Int1024,
920 crate::wide_int::Int2048,
921 crate::wide_int::Int2048,
922 wide_trig_d153,
923 152
924);
925#[cfg(any(feature = "d153", feature = "wide"))]
927crate::macros::conversions::decl_cross_width_widening!(wide D153, crate::wide_int::I512, D38, i128);
928#[cfg(all(any(feature = "d153", feature = "wide"), any(feature = "d76", feature = "wide")))]
929crate::macros::conversions::decl_cross_width_widening!(wide D153, crate::wide_int::I512, D76, crate::wide_int::I256);
930#[cfg(all(any(feature = "d153", feature = "wide"), any(feature = "d76", feature = "wide")))]
932crate::macros::conversions::decl_cross_width_narrowing!(wide D76, crate::wide_int::I256, D153, crate::wide_int::I512);
933#[cfg(any(feature = "d153", feature = "wide"))]
934crate::macros::conversions::decl_cross_width_narrowing!(wide D38, i128, D153, crate::wide_int::I512);
935
936#[cfg(all(any(feature = "d76", feature = "wide"), any(feature = "d115", feature = "wide")))]
939impl<const SCALE: u32> D76<SCALE> {
940 #[inline]
943 #[must_use]
944 pub fn widen(self) -> D115<SCALE> {
945 self.into()
946 }
947}
948
949#[cfg(any(feature = "d153", feature = "wide"))]
950impl<const SCALE: u32> D153<SCALE> {
951 #[cfg(any(feature = "d115", feature = "wide"))]
955 #[inline]
956 pub fn narrow(self) -> Result<D115<SCALE>, crate::support::error::ConvertError> {
957 self.try_into()
958 }
959}
960
961#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s0 = D153<0>;
963#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s1 = D153<1>;
964#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s2 = D153<2>;
965#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s4 = D153<4>;
966#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s6 = D153<6>;
967#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s9 = D153<9>;
968#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s12 = D153<12>;
969#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s15 = D153<15>;
970#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s18 = D153<18>;
971#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s20 = D153<20>;
972#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s24 = D153<24>;
973#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s28 = D153<28>;
974#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s32 = D153<32>;
975#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s35 = D153<35>;
977#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s38 = D153<38>;
978#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s50 = D153<50>;
979#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s57 = D153<57>;
980#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s75 = D153<75>;
982#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s76 = D153<76>;
983#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s100 = D153<100>;
984#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s115 = D153<115>;
985#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s140 = D153<140>;
986#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s150 = D153<150>;
988#[cfg(any(feature = "d153", feature = "wide"))] pub type D153s152 = D153<152>;
991
992#[cfg(any(feature = "d307", feature = "wide"))]
1010pub type D307<const SCALE: u32> = crate::D<crate::wide_int::Int1024, SCALE>;
1011
1012#[cfg(any(feature = "d307", feature = "wide"))]
1019impl<const SCALE: u32> Default for crate::D<crate::wide_int::Int1024, SCALE> {
1020 #[inline]
1021 fn default() -> Self {
1022 Self::ZERO
1023 }
1024}
1025
1026#[cfg(any(feature = "d307", feature = "wide"))]
1027crate::macros::full::decl_decimal_full!(
1028 wide D307,
1029 crate::wide_int::I1024,
1030 crate::wide_int::U1024,
1031 crate::wide_int::I2048,
1032 crate::wide_int::Int2048,
1033 crate::wide_int::Int4096,
1034 crate::wide_int::Int4096,
1035 wide_trig_d307,
1036 306
1037);
1038#[cfg(all(any(feature = "d307", feature = "wide"), any(feature = "d76", feature = "wide")))]
1040crate::macros::conversions::decl_cross_width_widening!(wide D307, crate::wide_int::I1024, D76, crate::wide_int::I256);
1041#[cfg(all(any(feature = "d307", feature = "wide"), any(feature = "d153", feature = "wide")))]
1042crate::macros::conversions::decl_cross_width_widening!(wide D307, crate::wide_int::I1024, D153, crate::wide_int::I512);
1043#[cfg(all(any(feature = "d307", feature = "wide"), any(feature = "d153", feature = "wide")))]
1045crate::macros::conversions::decl_cross_width_narrowing!(wide D153, crate::wide_int::I512, D307, crate::wide_int::I1024);
1046#[cfg(all(any(feature = "d307", feature = "wide"), any(feature = "d76", feature = "wide")))]
1047crate::macros::conversions::decl_cross_width_narrowing!(wide D76, crate::wide_int::I256, D307, crate::wide_int::I1024);
1048
1049#[cfg(all(any(feature = "d153", feature = "wide"), any(feature = "d230", feature = "wide")))]
1052impl<const SCALE: u32> D153<SCALE> {
1053 #[inline]
1056 #[must_use]
1057 pub fn widen(self) -> D230<SCALE> {
1058 self.into()
1059 }
1060}
1061
1062#[cfg(any(feature = "d307", feature = "wide"))]
1063impl<const SCALE: u32> D307<SCALE> {
1064 #[cfg(any(feature = "d230", feature = "wide"))]
1068 #[inline]
1069 pub fn narrow(self) -> Result<D230<SCALE>, crate::support::error::ConvertError> {
1070 self.try_into()
1071 }
1072
1073 #[cfg(any(feature = "d462", feature = "x-wide"))]
1076 #[inline]
1077 #[must_use]
1078 pub fn widen(self) -> D462<SCALE> {
1079 self.into()
1080 }
1081}
1082
1083#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s0 = D307<0>;
1085#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s1 = D307<1>;
1086#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s2 = D307<2>;
1087#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s4 = D307<4>;
1088#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s6 = D307<6>;
1089#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s9 = D307<9>;
1090#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s12 = D307<12>;
1091#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s15 = D307<15>;
1092#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s18 = D307<18>;
1093#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s20 = D307<20>;
1094#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s24 = D307<24>;
1095#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s28 = D307<28>;
1096#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s32 = D307<32>;
1097#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s35 = D307<35>;
1099#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s38 = D307<38>;
1100#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s50 = D307<50>;
1101#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s75 = D307<75>;
1102#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s100 = D307<100>;
1103#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s115 = D307<115>;
1104#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s150 = D307<150>;
1106#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s153 = D307<153>;
1107#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s200 = D307<200>;
1108#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s230 = D307<230>;
1109#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s275 = D307<275>;
1110#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s300 = D307<300>;
1112#[cfg(any(feature = "d307", feature = "wide"))] pub type D307s306 = D307<306>;
1115
1116#[cfg(any(feature = "d57", feature = "wide"))]
1143pub type D57<const SCALE: u32> = crate::D<crate::wide_int::Int192, SCALE>;
1144
1145#[cfg(any(feature = "d57", feature = "wide"))]
1152impl<const SCALE: u32> Default for crate::D<crate::wide_int::Int192, SCALE> {
1153 #[inline]
1154 fn default() -> Self { Self::ZERO }
1155}
1156
1157#[cfg(any(feature = "d57", feature = "wide"))]
1158crate::macros::full::decl_decimal_full!(
1159 wide D57,
1160 crate::wide_int::I192,
1161 crate::wide_int::U192,
1162 crate::wide_int::I384,
1163 crate::wide_int::Int384,
1164 crate::wide_int::Int512,
1165 crate::wide_int::Int1024,
1166 wide_trig_d57,
1167 56
1168);
1169#[cfg(any(feature = "d57", feature = "wide"))]
1170pub type D57s0 = D57<0>;
1171#[cfg(any(feature = "d57", feature = "wide"))]
1172pub type D57s1 = D57<1>;
1173#[cfg(any(feature = "d57", feature = "wide"))]
1174pub type D57s2 = D57<2>;
1175#[cfg(any(feature = "d57", feature = "wide"))]
1176pub type D57s4 = D57<4>;
1177#[cfg(any(feature = "d57", feature = "wide"))]
1178pub type D57s6 = D57<6>;
1179#[cfg(any(feature = "d57", feature = "wide"))]
1180pub type D57s9 = D57<9>;
1181#[cfg(any(feature = "d57", feature = "wide"))]
1182pub type D57s12 = D57<12>;
1183#[cfg(any(feature = "d57", feature = "wide"))]
1184pub type D57s18 = D57<18>;
1185#[cfg(any(feature = "d57", feature = "wide"))]
1186pub type D57s20 = D57<20>;
1187#[cfg(any(feature = "d57", feature = "wide"))]
1188pub type D57s24 = D57<24>;
1189#[cfg(any(feature = "d57", feature = "wide"))]
1190pub type D57s28 = D57<28>;
1191#[cfg(any(feature = "d57", feature = "wide"))]
1192pub type D57s32 = D57<32>;
1193#[cfg(any(feature = "d57", feature = "wide"))]
1194pub type D57s38 = D57<38>;
1195#[cfg(any(feature = "d57", feature = "wide"))]
1196pub type D57s42 = D57<42>;
1197#[cfg(any(feature = "d57", feature = "wide"))]
1198pub type D57s48 = D57<48>;
1199#[cfg(any(feature = "d57", feature = "wide"))]
1200pub type D57s52 = D57<52>;
1201#[cfg(any(feature = "d57", feature = "wide"))]
1204pub type D57s56 = D57<56>;
1205
1206#[cfg(any(feature = "d115", feature = "wide"))]
1219pub type D115<const SCALE: u32> = crate::D<crate::wide_int::Int384, SCALE>;
1220
1221#[cfg(any(feature = "d115", feature = "wide"))]
1228impl<const SCALE: u32> Default for crate::D<crate::wide_int::Int384, SCALE> {
1229 #[inline]
1230 fn default() -> Self { Self::ZERO }
1231}
1232
1233#[cfg(any(feature = "d115", feature = "wide"))]
1234crate::macros::full::decl_decimal_full!(
1235 wide D115,
1236 crate::wide_int::I384,
1237 crate::wide_int::U384,
1238 crate::wide_int::I768,
1239 crate::wide_int::Int768,
1240 crate::wide_int::Int1024,
1241 crate::wide_int::Int1024,
1242 wide_trig_d115,
1243 114
1244);
1245#[cfg(any(feature = "d115", feature = "wide"))]
1246pub type D115s0 = D115<0>;
1247#[cfg(any(feature = "d115", feature = "wide"))]
1248pub type D115s1 = D115<1>;
1249#[cfg(any(feature = "d115", feature = "wide"))]
1250pub type D115s4 = D115<4>;
1251#[cfg(any(feature = "d115", feature = "wide"))]
1252pub type D115s8 = D115<8>;
1253#[cfg(any(feature = "d115", feature = "wide"))]
1254pub type D115s16 = D115<16>;
1255#[cfg(any(feature = "d115", feature = "wide"))]
1256pub type D115s24 = D115<24>;
1257#[cfg(any(feature = "d115", feature = "wide"))]
1258pub type D115s32 = D115<32>;
1259#[cfg(any(feature = "d115", feature = "wide"))]
1260pub type D115s38 = D115<38>;
1261#[cfg(any(feature = "d115", feature = "wide"))]
1262pub type D115s50 = D115<50>;
1263#[cfg(any(feature = "d115", feature = "wide"))]
1264pub type D115s57 = D115<57>;
1265#[cfg(any(feature = "d115", feature = "wide"))]
1266pub type D115s64 = D115<64>;
1267#[cfg(any(feature = "d115", feature = "wide"))]
1268pub type D115s76 = D115<76>;
1269#[cfg(any(feature = "d115", feature = "wide"))]
1270pub type D115s90 = D115<90>;
1271#[cfg(any(feature = "d115", feature = "wide"))]
1272pub type D115s100 = D115<100>;
1273#[cfg(any(feature = "d115", feature = "wide"))]
1274pub type D115s110 = D115<110>;
1275#[cfg(any(feature = "d115", feature = "wide"))]
1278pub type D115s114 = D115<114>;
1279
1280#[cfg(any(feature = "d230", feature = "wide"))]
1293pub type D230<const SCALE: u32> = crate::D<crate::wide_int::Int768, SCALE>;
1294
1295#[cfg(any(feature = "d230", feature = "wide"))]
1302impl<const SCALE: u32> Default for crate::D<crate::wide_int::Int768, SCALE> {
1303 #[inline]
1304 fn default() -> Self { Self::ZERO }
1305}
1306
1307#[cfg(any(feature = "d230", feature = "wide"))]
1308crate::macros::full::decl_decimal_full!(
1309 wide D230,
1310 crate::wide_int::I768,
1311 crate::wide_int::U768,
1312 crate::wide_int::I1536,
1313 crate::wide_int::Int1536,
1314 crate::wide_int::Int3072,
1315 crate::wide_int::Int3072,
1316 wide_trig_d230,
1317 229
1318);
1319#[cfg(any(feature = "d230", feature = "wide"))]
1320pub type D230s0 = D230<0>;
1321#[cfg(any(feature = "d230", feature = "wide"))]
1322pub type D230s1 = D230<1>;
1323#[cfg(any(feature = "d230", feature = "wide"))]
1324pub type D230s6 = D230<6>;
1325#[cfg(any(feature = "d230", feature = "wide"))]
1326pub type D230s18 = D230<18>;
1327#[cfg(any(feature = "d230", feature = "wide"))]
1328pub type D230s38 = D230<38>;
1329#[cfg(any(feature = "d230", feature = "wide"))]
1330pub type D230s57 = D230<57>;
1331#[cfg(any(feature = "d230", feature = "wide"))]
1332pub type D230s75 = D230<75>;
1333#[cfg(any(feature = "d230", feature = "wide"))]
1334pub type D230s100 = D230<100>;
1335#[cfg(any(feature = "d230", feature = "wide"))]
1336pub type D230s115 = D230<115>;
1337#[cfg(any(feature = "d230", feature = "wide"))]
1338pub type D230s140 = D230<140>;
1339#[cfg(any(feature = "d230", feature = "wide"))]
1340pub type D230s153 = D230<153>;
1341#[cfg(any(feature = "d230", feature = "wide"))]
1342pub type D230s175 = D230<175>;
1343#[cfg(any(feature = "d230", feature = "wide"))]
1344pub type D230s200 = D230<200>;
1345#[cfg(any(feature = "d230", feature = "wide"))]
1346pub type D230s215 = D230<215>;
1347#[cfg(any(feature = "d230", feature = "wide"))]
1348pub type D230s225 = D230<225>;
1349#[cfg(any(feature = "d230", feature = "wide"))]
1352pub type D230s229 = D230<229>;
1353
1354#[cfg(any(feature = "d462", feature = "x-wide"))]
1367pub type D462<const SCALE: u32> = crate::D<crate::wide_int::Int1536, SCALE>;
1368
1369#[cfg(any(feature = "d462", feature = "x-wide"))]
1376impl<const SCALE: u32> Default for crate::D<crate::wide_int::Int1536, SCALE> {
1377 #[inline]
1378 fn default() -> Self { Self::ZERO }
1379}
1380
1381#[cfg(any(feature = "d462", feature = "x-wide"))]
1382crate::macros::full::decl_decimal_full!(
1383 wide D462,
1384 crate::wide_int::I1536,
1385 crate::wide_int::U1536,
1386 crate::wide_int::I3072,
1387 crate::wide_int::Int3072,
1388 crate::wide_int::Int4096,
1389 crate::wide_int::Int4096,
1390 wide_trig_d462,
1391 461
1392);
1393#[cfg(any(feature = "d462", feature = "x-wide"))]
1394pub type D462s0 = D462<0>;
1395#[cfg(any(feature = "d462", feature = "x-wide"))]
1396pub type D462s1 = D462<1>;
1397#[cfg(any(feature = "d462", feature = "x-wide"))]
1398pub type D462s18 = D462<18>;
1399#[cfg(any(feature = "d462", feature = "x-wide"))]
1400pub type D462s38 = D462<38>;
1401#[cfg(any(feature = "d462", feature = "x-wide"))]
1402pub type D462s75 = D462<75>;
1403#[cfg(any(feature = "d462", feature = "x-wide"))]
1404pub type D462s115 = D462<115>;
1405#[cfg(any(feature = "d462", feature = "x-wide"))]
1406pub type D462s153 = D462<153>;
1407#[cfg(any(feature = "d462", feature = "x-wide"))]
1408pub type D462s200 = D462<200>;
1409#[cfg(any(feature = "d462", feature = "x-wide"))]
1410pub type D462s230 = D462<230>;
1411#[cfg(any(feature = "d462", feature = "x-wide"))]
1412pub type D462s275 = D462<275>;
1413#[cfg(any(feature = "d462", feature = "x-wide"))]
1414pub type D462s307 = D462<307>;
1415#[cfg(any(feature = "d462", feature = "x-wide"))]
1416pub type D462s350 = D462<350>;
1417#[cfg(any(feature = "d462", feature = "x-wide"))]
1418pub type D462s400 = D462<400>;
1419#[cfg(any(feature = "d462", feature = "x-wide"))]
1420pub type D462s440 = D462<440>;
1421#[cfg(any(feature = "d462", feature = "x-wide"))]
1422pub type D462s460 = D462<460>;
1423#[cfg(any(feature = "d462", feature = "x-wide"))]
1426pub type D462s461 = D462<461>;
1427
1428#[cfg(any(feature = "d616", feature = "x-wide"))]
1442pub type D616<const SCALE: u32> = crate::D<crate::wide_int::Int2048, SCALE>;
1443
1444#[cfg(any(feature = "d616", feature = "x-wide"))]
1451impl<const SCALE: u32> Default for crate::D<crate::wide_int::Int2048, SCALE> {
1452 #[inline]
1453 fn default() -> Self { Self::ZERO }
1454}
1455
1456#[cfg(any(feature = "d616", feature = "x-wide"))]
1457crate::macros::full::decl_decimal_full!(
1458 wide D616,
1459 crate::wide_int::I2048,
1460 crate::wide_int::U2048,
1461 crate::wide_int::I4096,
1462 crate::wide_int::Int4096,
1463 crate::wide_int::Int8192,
1464 crate::wide_int::Int8192,
1465 wide_trig_d616,
1466 615
1467);
1468#[cfg(any(feature = "d616", feature = "x-wide"))]
1469pub type D616s0 = D616<0>;
1470#[cfg(any(feature = "d616", feature = "x-wide"))]
1471pub type D616s1 = D616<1>;
1472#[cfg(any(feature = "d616", feature = "x-wide"))]
1473pub type D616s38 = D616<38>;
1474#[cfg(any(feature = "d616", feature = "x-wide"))]
1475pub type D616s75 = D616<75>;
1476#[cfg(any(feature = "d616", feature = "x-wide"))]
1477pub type D616s115 = D616<115>;
1478#[cfg(any(feature = "d616", feature = "x-wide"))]
1479pub type D616s153 = D616<153>;
1480#[cfg(any(feature = "d616", feature = "x-wide"))]
1481pub type D616s200 = D616<200>;
1482#[cfg(any(feature = "d616", feature = "x-wide"))]
1483pub type D616s230 = D616<230>;
1484#[cfg(any(feature = "d616", feature = "x-wide"))]
1485pub type D616s275 = D616<275>;
1486#[cfg(any(feature = "d616", feature = "x-wide"))]
1487pub type D616s308 = D616<308>;
1488#[cfg(any(feature = "d616", feature = "x-wide"))]
1489pub type D616s380 = D616<380>;
1490#[cfg(any(feature = "d616", feature = "x-wide"))]
1491pub type D616s462 = D616<462>;
1492#[cfg(any(feature = "d616", feature = "x-wide"))]
1493pub type D616s500 = D616<500>;
1494#[cfg(any(feature = "d616", feature = "x-wide"))]
1495pub type D616s555 = D616<555>;
1496#[cfg(any(feature = "d616", feature = "x-wide"))]
1497pub type D616s600 = D616<600>;
1498#[cfg(any(feature = "d616", feature = "x-wide"))]
1501pub type D616s615 = D616<615>;
1502
1503#[cfg(any(feature = "d924", feature = "xx-wide"))]
1516pub type D924<const SCALE: u32> = crate::D<crate::wide_int::Int3072, SCALE>;
1517
1518#[cfg(any(feature = "d924", feature = "xx-wide"))]
1525impl<const SCALE: u32> Default for crate::D<crate::wide_int::Int3072, SCALE> {
1526 #[inline]
1527 fn default() -> Self { Self::ZERO }
1528}
1529
1530#[cfg(any(feature = "d924", feature = "xx-wide"))]
1531crate::macros::full::decl_decimal_full!(
1532 wide D924,
1533 crate::wide_int::I3072,
1534 crate::wide_int::U3072,
1535 crate::wide_int::I6144,
1536 crate::wide_int::Int6144,
1537 crate::wide_int::Int12288,
1538 crate::wide_int::Int12288,
1539 wide_trig_d924,
1540 923
1541);
1542#[cfg(any(feature = "d924", feature = "xx-wide"))]
1543pub type D924s0 = D924<0>;
1544#[cfg(any(feature = "d924", feature = "xx-wide"))]
1545pub type D924s1 = D924<1>;
1546#[cfg(any(feature = "d924", feature = "xx-wide"))]
1547pub type D924s75 = D924<75>;
1548#[cfg(any(feature = "d924", feature = "xx-wide"))]
1549pub type D924s153 = D924<153>;
1550#[cfg(any(feature = "d924", feature = "xx-wide"))]
1551pub type D924s230 = D924<230>;
1552#[cfg(any(feature = "d924", feature = "xx-wide"))]
1553pub type D924s307 = D924<307>;
1554#[cfg(any(feature = "d924", feature = "xx-wide"))]
1555pub type D924s400 = D924<400>;
1556#[cfg(any(feature = "d924", feature = "xx-wide"))]
1557pub type D924s461 = D924<461>;
1558#[cfg(any(feature = "d924", feature = "xx-wide"))]
1559pub type D924s462 = D924<462>;
1560#[cfg(any(feature = "d924", feature = "xx-wide"))]
1561pub type D924s500 = D924<500>;
1562#[cfg(any(feature = "d924", feature = "xx-wide"))]
1563pub type D924s616 = D924<616>;
1564#[cfg(any(feature = "d924", feature = "xx-wide"))]
1565pub type D924s700 = D924<700>;
1566#[cfg(any(feature = "d924", feature = "xx-wide"))]
1567pub type D924s800 = D924<800>;
1568#[cfg(any(feature = "d924", feature = "xx-wide"))]
1569pub type D924s860 = D924<860>;
1570#[cfg(any(feature = "d924", feature = "xx-wide"))]
1571pub type D924s900 = D924<900>;
1572#[cfg(any(feature = "d924", feature = "xx-wide"))]
1573pub type D924s920 = D924<920>;
1574#[cfg(any(feature = "d924", feature = "xx-wide"))]
1577pub type D924s923 = D924<923>;
1578
1579#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1592pub type D1232<const SCALE: u32> = crate::D<crate::wide_int::Int4096, SCALE>;
1593
1594#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1601impl<const SCALE: u32> Default for crate::D<crate::wide_int::Int4096, SCALE> {
1602 #[inline]
1603 fn default() -> Self { Self::ZERO }
1604}
1605
1606#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1607crate::macros::full::decl_decimal_full!(
1608 wide D1232,
1609 crate::wide_int::I4096,
1610 crate::wide_int::U4096,
1611 crate::wide_int::I8192,
1612 crate::wide_int::Int8192,
1613 crate::wide_int::Int16384,
1614 crate::wide_int::Int16384,
1615 wide_trig_d1232,
1616 1231
1617);
1618#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1619pub type D1232s0 = D1232<0>;
1620#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1621pub type D1232s1 = D1232<1>;
1622#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1623pub type D1232s75 = D1232<75>;
1624#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1625pub type D1232s153 = D1232<153>;
1626#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1627pub type D1232s230 = D1232<230>;
1628#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1629pub type D1232s307 = D1232<307>;
1630#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1631pub type D1232s461 = D1232<461>;
1632#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1633pub type D1232s616 = D1232<616>;
1634#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1635pub type D1232s700 = D1232<700>;
1636#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1637pub type D1232s800 = D1232<800>;
1638#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1639pub type D1232s900 = D1232<900>;
1640#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1641pub type D1232s924 = D1232<924>;
1642#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1643pub type D1232s1000 = D1232<1000>;
1644#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1645pub type D1232s1100 = D1232<1100>;
1646#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1647pub type D1232s1180 = D1232<1180>;
1648#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1649pub type D1232s1220 = D1232<1220>;
1650#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1651pub type D1232s1230 = D1232<1230>;
1652#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1655pub type D1232s1231 = D1232<1231>;
1656
1657#[cfg(any(feature = "d57", feature = "wide"))]
1681crate::macros::conversions::decl_cross_width_widening!(wide D57, crate::wide_int::I192, D38, i128);
1682#[cfg(any(feature = "d57", feature = "wide"))]
1683crate::macros::conversions::decl_cross_width_narrowing!(wide D38, i128, D57, crate::wide_int::I192);
1684
1685#[cfg(all(any(feature = "d57", feature = "wide"), any(feature = "d76", feature = "wide")))]
1687crate::macros::conversions::decl_cross_width_widening!(wide D76, crate::wide_int::I256, D57, crate::wide_int::I192);
1688#[cfg(all(any(feature = "d57", feature = "wide"), any(feature = "d76", feature = "wide")))]
1689crate::macros::conversions::decl_cross_width_narrowing!(wide D57, crate::wide_int::I192, D76, crate::wide_int::I256);
1690
1691#[cfg(all(any(feature = "d76", feature = "wide"), any(feature = "d115", feature = "wide")))]
1693crate::macros::conversions::decl_cross_width_widening!(wide D115, crate::wide_int::I384, D76, crate::wide_int::I256);
1694#[cfg(all(any(feature = "d76", feature = "wide"), any(feature = "d115", feature = "wide")))]
1695crate::macros::conversions::decl_cross_width_narrowing!(wide D76, crate::wide_int::I256, D115, crate::wide_int::I384);
1696
1697#[cfg(all(any(feature = "d115", feature = "wide"), any(feature = "d153", feature = "wide")))]
1699crate::macros::conversions::decl_cross_width_widening!(wide D153, crate::wide_int::I512, D115, crate::wide_int::I384);
1700#[cfg(all(any(feature = "d115", feature = "wide"), any(feature = "d153", feature = "wide")))]
1701crate::macros::conversions::decl_cross_width_narrowing!(wide D115, crate::wide_int::I384, D153, crate::wide_int::I512);
1702
1703#[cfg(all(any(feature = "d153", feature = "wide"), any(feature = "d230", feature = "wide")))]
1705crate::macros::conversions::decl_cross_width_widening!(wide D230, crate::wide_int::I768, D153, crate::wide_int::I512);
1706#[cfg(all(any(feature = "d153", feature = "wide"), any(feature = "d230", feature = "wide")))]
1707crate::macros::conversions::decl_cross_width_narrowing!(wide D153, crate::wide_int::I512, D230, crate::wide_int::I768);
1708
1709#[cfg(all(any(feature = "d230", feature = "wide"), any(feature = "d307", feature = "wide")))]
1711crate::macros::conversions::decl_cross_width_widening!(wide D307, crate::wide_int::I1024, D230, crate::wide_int::I768);
1712#[cfg(all(any(feature = "d230", feature = "wide"), any(feature = "d307", feature = "wide")))]
1713crate::macros::conversions::decl_cross_width_narrowing!(wide D230, crate::wide_int::I768, D307, crate::wide_int::I1024);
1714
1715#[cfg(all(any(feature = "d307", feature = "wide"), any(feature = "d462", feature = "x-wide")))]
1717crate::macros::conversions::decl_cross_width_widening!(wide D462, crate::wide_int::I1536, D307, crate::wide_int::I1024);
1718#[cfg(all(any(feature = "d307", feature = "wide"), any(feature = "d462", feature = "x-wide")))]
1719crate::macros::conversions::decl_cross_width_narrowing!(wide D307, crate::wide_int::I1024, D462, crate::wide_int::I1536);
1720
1721#[cfg(all(any(feature = "d462", feature = "x-wide"), any(feature = "d616", feature = "x-wide")))]
1723crate::macros::conversions::decl_cross_width_widening!(wide D616, crate::wide_int::I2048, D462, crate::wide_int::I1536);
1724#[cfg(all(any(feature = "d462", feature = "x-wide"), any(feature = "d616", feature = "x-wide")))]
1725crate::macros::conversions::decl_cross_width_narrowing!(wide D462, crate::wide_int::I1536, D616, crate::wide_int::I2048);
1726
1727#[cfg(all(any(feature = "d616", feature = "x-wide"), any(feature = "d924", feature = "xx-wide")))]
1729crate::macros::conversions::decl_cross_width_widening!(wide D924, crate::wide_int::I3072, D616, crate::wide_int::I2048);
1730#[cfg(all(any(feature = "d616", feature = "x-wide"), any(feature = "d924", feature = "xx-wide")))]
1731crate::macros::conversions::decl_cross_width_narrowing!(wide D616, crate::wide_int::I2048, D924, crate::wide_int::I3072);
1732
1733#[cfg(all(any(feature = "d924", feature = "xx-wide"), any(feature = "d1232", feature = "xx-wide")))]
1735crate::macros::conversions::decl_cross_width_widening!(wide D1232, crate::wide_int::I4096, D924, crate::wide_int::I3072);
1736#[cfg(all(any(feature = "d924", feature = "xx-wide"), any(feature = "d1232", feature = "xx-wide")))]
1737crate::macros::conversions::decl_cross_width_narrowing!(wide D924, crate::wide_int::I3072, D1232, crate::wide_int::I4096);
1738
1739#[cfg(any(feature = "d57", feature = "wide"))]
1747impl<const SCALE: u32> D57<SCALE> {
1748 #[inline]
1751 pub fn narrow(self) -> Result<D38<SCALE>, crate::support::error::ConvertError> { self.try_into() }
1752 #[inline] #[must_use]
1754 pub fn widen(self) -> D76<SCALE> { self.into() }
1755}
1756
1757#[cfg(any(feature = "d115", feature = "wide"))]
1758impl<const SCALE: u32> D115<SCALE> {
1759 #[inline]
1761 pub fn narrow(self) -> Result<D76<SCALE>, crate::support::error::ConvertError> { self.try_into() }
1762 #[inline] #[must_use]
1764 pub fn widen(self) -> D153<SCALE> { self.into() }
1765}
1766
1767#[cfg(any(feature = "d230", feature = "wide"))]
1768impl<const SCALE: u32> D230<SCALE> {
1769 #[inline]
1771 pub fn narrow(self) -> Result<D153<SCALE>, crate::support::error::ConvertError> { self.try_into() }
1772 #[inline] #[must_use]
1774 pub fn widen(self) -> D307<SCALE> { self.into() }
1775}
1776
1777#[cfg(any(feature = "d462", feature = "x-wide"))]
1778impl<const SCALE: u32> D462<SCALE> {
1779 #[inline]
1781 pub fn narrow(self) -> Result<D307<SCALE>, crate::support::error::ConvertError> { self.try_into() }
1782 #[inline] #[must_use]
1784 pub fn widen(self) -> D616<SCALE> { self.into() }
1785}
1786
1787#[cfg(any(feature = "d616", feature = "x-wide"))]
1788impl<const SCALE: u32> D616<SCALE> {
1789 #[inline]
1791 pub fn narrow(self) -> Result<D462<SCALE>, crate::support::error::ConvertError> { self.try_into() }
1792}
1793
1794#[cfg(all(
1799 any(feature = "d616", feature = "x-wide"),
1800 any(feature = "d924", feature = "xx-wide"),
1801))]
1802impl<const SCALE: u32> D616<SCALE> {
1803 #[inline] #[must_use]
1805 pub fn widen(self) -> D924<SCALE> { self.into() }
1806}
1807
1808#[cfg(any(feature = "d924", feature = "xx-wide"))]
1809impl<const SCALE: u32> D924<SCALE> {
1810 #[inline]
1812 pub fn narrow(self) -> Result<D616<SCALE>, crate::support::error::ConvertError> { self.try_into() }
1813 #[inline] #[must_use]
1815 pub fn widen(self) -> D1232<SCALE> { self.into() }
1816}
1817
1818#[cfg(any(feature = "d1232", feature = "xx-wide"))]
1819impl<const SCALE: u32> D1232<SCALE> {
1820 #[inline]
1823 pub fn narrow(self) -> Result<D924<SCALE>, crate::support::error::ConvertError> { self.try_into() }
1824}
1825
1826#[cfg(test)]
1827mod tests {
1828 use super::*;
1829
1830 #[test]
1832 fn from_bits_to_bits_round_trip() {
1833 let raw: i128 = 1_500_000_000_000;
1834 let v: D38s12 = D38s12::from_bits(raw);
1835 assert_eq!(v.to_bits(), raw);
1836 }
1837
1838 #[test]
1840 fn zero_is_zero_bits() {
1841 assert_eq!(D38s12::ZERO.to_bits(), 0);
1842 }
1843
1844 #[test]
1846 fn equal_by_underlying_bits() {
1847 assert_eq!(
1848 D38s12::from_bits(42_000_000_000_000),
1849 D38s12::from_bits(42_000_000_000_000)
1850 );
1851 assert_ne!(D38s12::from_bits(42), D38s12::from_bits(43));
1852 }
1853
1854 #[test]
1856 fn ord_by_underlying_bits() {
1857 assert!(D38s12::from_bits(1) < D38s12::from_bits(2));
1858 assert!(D38s12::from_bits(-1) < D38s12::from_bits(0));
1859 }
1860
1861 #[test]
1863 fn multiplier_is_ten_to_scale() {
1864 assert_eq!(D38s12::multiplier(), 1_000_000_000_000_i128);
1865 }
1866
1867 #[test]
1869 fn scale_const_matches_type_parameter() {
1870 assert_eq!(D38s12::SCALE, 12);
1871 const N: u32 = D38s12::SCALE;
1872 assert_eq!(N, 12);
1873 }
1874
1875 #[test]
1878 fn scale_method_matches_type_parameter() {
1879 assert_eq!(D38s12::ZERO.scale(), 12);
1880 assert_eq!(D38s12::ONE.scale(), 12);
1881 assert_eq!(D38s12::from_bits(i128::MAX).scale(), 12);
1882 assert_eq!(D38s12::from_bits(-7).scale(), 12);
1883 }
1884
1885 #[test]
1887 fn scale_at_other_scales() {
1888 type D6 = super::D38<6>;
1889 type D0 = super::D38<0>;
1890 type D38 = super::D38<38>;
1891 assert_eq!(D6::SCALE, 6);
1892 assert_eq!(D0::SCALE, 0);
1893 assert_eq!(D38::SCALE, 38);
1894 assert_eq!(D6::ZERO.scale(), 6);
1895 assert_eq!(D0::ZERO.scale(), 0);
1896 assert_eq!(D38::ZERO.scale(), 38);
1897 }
1898
1899 #[test]
1901 fn one_has_scaled_bit_pattern() {
1902 assert_eq!(D38s12::ONE.to_bits(), 1_000_000_000_000_i128);
1903 }
1904
1905 #[test]
1907 fn max_is_i128_max() {
1908 assert_eq!(D38s12::MAX.to_bits(), i128::MAX);
1909 }
1910
1911 #[test]
1913 fn min_is_i128_min() {
1914 assert_eq!(D38s12::MIN.to_bits(), i128::MIN);
1915 }
1916
1917 #[test]
1919 fn one_is_not_zero() {
1920 assert_ne!(D38s12::ONE, D38s12::ZERO);
1921 assert!(D38s12::ONE.is_positive());
1922 }
1923
1924 #[test]
1926 fn multiplier_at_other_scales() {
1927 type D6 = super::D38<6>;
1928 assert_eq!(D6::multiplier(), 1_000_000_i128);
1929 assert_eq!(D6::ONE.to_bits(), 1_000_000_i128);
1930
1931 type D0 = super::D38<0>;
1932 assert_eq!(D0::multiplier(), 1_i128);
1933 assert_eq!(D0::ONE.to_bits(), 1_i128);
1934 }
1935
1936 #[test]
1939 fn d9_basics() {
1940 assert_eq!(super::D9s2::ZERO.to_bits(), 0_i32);
1941 assert_eq!(super::D9s2::ONE.to_bits(), 100_i32);
1942 assert_eq!(super::D9s2::MAX.to_bits(), i32::MAX);
1943 assert_eq!(super::D9s2::MIN.to_bits(), i32::MIN);
1944 assert_eq!(super::D9s2::multiplier(), 100_i32);
1945 assert_eq!(super::D9s2::SCALE, 2);
1946 }
1947
1948 #[test]
1949 fn d18_basics() {
1950 assert_eq!(super::D18s9::ZERO.to_bits(), 0_i64);
1951 assert_eq!(super::D18s9::ONE.to_bits(), 1_000_000_000_i64);
1952 assert_eq!(super::D18s9::multiplier(), 1_000_000_000_i64);
1953 assert_eq!(super::D18s9::SCALE, 9);
1954 }
1955
1956 #[test]
1957 fn d9_arithmetic() {
1958 let a = super::D9s2::from_bits(150); let b = super::D9s2::from_bits(250); assert_eq!((a + b).to_bits(), 400);
1961 assert_eq!((b - a).to_bits(), 100);
1962 assert_eq!((-a).to_bits(), -150);
1963
1964 let x = super::D9s2::from_bits(200); let y = super::D9s2::from_bits(300); assert_eq!((x * y).to_bits(), 600); assert_eq!((y / x).to_bits(), 150); assert_eq!((y % x).to_bits(), 100); }
1970
1971 #[test]
1972 fn d18_arithmetic() {
1973 let a = super::D18s9::from_bits(1_500_000_000); let b = super::D18s9::from_bits(2_500_000_000); assert_eq!((a + b).to_bits(), 4_000_000_000);
1976 assert_eq!((b - a).to_bits(), 1_000_000_000);
1977 assert_eq!((-a).to_bits(), -1_500_000_000);
1978
1979 let x = super::D18s9::from_bits(2_000_000_000); let y = super::D18s9::from_bits(3_000_000_000); assert_eq!((x * y).to_bits(), 6_000_000_000);
1982 assert_eq!((y / x).to_bits(), 1_500_000_000);
1983 assert_eq!((y % x).to_bits(), 1_000_000_000);
1984 }
1985
1986 #[test]
1987 fn d9_display() {
1988 let v: super::D9s2 = super::D9s2::from_bits(150); let s = alloc::format!("{}", v);
1990 assert_eq!(s, "1.50");
1991 let neg: super::D9s2 = super::D9s2::from_bits(-2050); assert_eq!(alloc::format!("{}", neg), "-20.50");
1993 let zero: super::D9s2 = super::D9s2::ZERO;
1994 assert_eq!(alloc::format!("{}", zero), "0.00");
1995 let int_only: super::D9s0 = super::D9s0::from_bits(42);
1996 assert_eq!(alloc::format!("{}", int_only), "42");
1997 }
1998
1999 #[test]
2000 fn d18_display() {
2001 let v: super::D18s9 = super::D18s9::from_bits(1_500_000_000); assert_eq!(alloc::format!("{}", v), "1.500000000");
2003 let neg: super::D18s9 = super::D18s9::from_bits(-1_500_000_000);
2004 assert_eq!(alloc::format!("{}", neg), "-1.500000000");
2005 }
2006
2007 #[test]
2008 fn d9_debug() {
2009 let v: super::D9s2 = super::D9s2::from_bits(150);
2010 let s = alloc::format!("{:?}", v);
2011 assert_eq!(s, "D9<2>(1.50)");
2012 }
2013
2014 #[test]
2015 fn cross_width_widening_d9_to_d18() {
2016 let small: super::D9s2 = super::D9s2::from_bits(150);
2017 let wider: super::D18s2 = small.into();
2018 assert_eq!(wider.to_bits(), 150_i64);
2019 }
2020
2021 #[test]
2022 fn cross_width_widening_d9_to_d38() {
2023 let small: super::D9s2 = super::D9s2::from_bits(-150);
2024 let wider: super::D38s2 = small.into();
2025 assert_eq!(wider.to_bits(), -150_i128);
2026 }
2027
2028 #[test]
2029 fn cross_width_widening_d18_to_d38() {
2030 let mid: super::D18s9 = super::D18s9::from_bits(i64::MAX);
2031 let wider: super::D38s9 = mid.into();
2032 assert_eq!(wider.to_bits(), i64::MAX as i128);
2033 }
2034
2035 #[test]
2036 fn cross_width_narrowing_d38_to_d18_in_range() {
2037 let wide: super::D38s9 = super::D38s9::from_bits(1_500_000_000);
2038 let narrow: super::D18s9 = wide.try_into().unwrap();
2039 assert_eq!(narrow.to_bits(), 1_500_000_000);
2040 }
2041
2042 #[test]
2043 fn cross_width_narrowing_d38_to_d18_out_of_range() {
2044 let wide: super::D38s9 = super::D38s9::from_bits(i128::MAX);
2045 let narrow: Result<super::D18s9, _> = wide.try_into();
2046 assert!(narrow.is_err());
2047 }
2048
2049 #[test]
2050 fn cross_width_narrowing_d18_to_d9_in_range() {
2051 let mid: super::D18s2 = super::D18s2::from_bits(150);
2052 let narrow: super::D9s2 = mid.try_into().unwrap();
2053 assert_eq!(narrow.to_bits(), 150);
2054 }
2055
2056 #[test]
2057 fn cross_width_narrowing_d18_to_d9_out_of_range() {
2058 let mid: super::D18s2 = super::D18s2::from_bits(i64::MAX);
2059 let narrow: Result<super::D9s2, _> = mid.try_into();
2060 assert!(narrow.is_err());
2061 }
2062
2063 #[test]
2064 fn d9_consts() {
2065 if !crate::support::rounding::DEFAULT_IS_HALF_TO_EVEN { return; }
2066 use crate::types::consts::DecimalConstants;
2067 type D9s4 = super::D9<4>;
2068 assert_eq!(D9s4::pi().to_bits(), 31416);
2070 assert_eq!(D9s4::e().to_bits(), 27183);
2072 }
2073
2074 #[test]
2075 fn d9_from_str() {
2076 use core::str::FromStr;
2077 let v = super::D9s2::from_str("1.50").unwrap();
2078 assert_eq!(v.to_bits(), 150);
2079 let neg = super::D9s2::from_str("-20.50").unwrap();
2080 assert_eq!(neg.to_bits(), -2050);
2081 assert!(super::D9s2::from_str("1000000000000.00").is_err());
2083 }
2084
2085 #[test]
2086 fn d18_from_str() {
2087 use core::str::FromStr;
2088 let v = super::D18s9::from_str("1.500000000").unwrap();
2089 assert_eq!(v.to_bits(), 1_500_000_000);
2090 let neg = super::D18s9::from_str("-1.500000000").unwrap();
2091 assert_eq!(neg.to_bits(), -1_500_000_000);
2092 }
2093
2094 #[test]
2095 fn d18_consts() {
2096 if !crate::support::rounding::DEFAULT_IS_HALF_TO_EVEN { return; }
2097 use crate::types::consts::DecimalConstants;
2098 type D18s12 = super::D18<12>;
2099 assert_eq!(D18s12::pi().to_bits(), 3_141_592_653_590);
2101 assert_eq!(D18s12::tau().to_bits(), 6_283_185_307_180);
2103 }
2104
2105 #[cfg(any(feature = "d76", feature = "wide"))]
2106 #[test]
2107 fn d76_basics() {
2108
2109 use crate::types::traits::arithmetic::DecimalArithmetic;
2110 use crate::wide_int::I256;
2111 assert_eq!(super::D76s2::ZERO.to_bits(), I256::from_str_radix("0", 10).unwrap());
2112 assert_eq!(super::D76s2::ONE.to_bits(), I256::from_str_radix("100", 10).unwrap());
2113 assert_eq!(super::D76s2::MAX.to_bits(), I256::MAX);
2114 assert_eq!(super::D76s2::MIN.to_bits(), I256::MIN);
2115 assert_eq!(super::D76s2::multiplier(), I256::from_str_radix("100", 10).unwrap());
2116 assert_eq!(super::D76s2::SCALE, 2);
2117 assert_eq!(super::D76s2::ZERO.scale(), 2);
2118 let m75 = super::D76s75::multiplier();
2120 assert_eq!(
2121 m75,
2122 I256::from_str_radix("1000000000000000000000000000000000000000000000000000000000000000000000000000", 10).unwrap()
2123 );
2124 assert_eq!(<super::D76s12 as DecimalArithmetic>::MAX_SCALE, 75);
2125 let raw = I256::from_str_radix("123456789012345678901234567890", 10).unwrap();
2127 assert_eq!(super::D76s12::from_bits(raw).to_bits(), raw);
2128 }
2129
2130 #[cfg(any(feature = "d76", feature = "wide"))]
2131 #[test]
2132 fn d76_arithmetic() {
2133 type D = super::D76<12>;
2134 let one = D::ONE;
2135 let two = D::from_bits(D::multiplier() + D::multiplier());
2136 let three = D::from_bits(D::multiplier() * crate::wide_int::I256::from_str_radix("3", 10).unwrap());
2137 assert_eq!((one + two), three);
2139 assert_eq!((three - one), two);
2140 assert_eq!((-one).to_bits(), -D::multiplier());
2141 let six = D::from_bits(D::multiplier() * crate::wide_int::I256::from_str_radix("6", 10).unwrap());
2143 assert_eq!((two * three), six);
2144 assert_eq!((six / two), three);
2146 assert_eq!((six % two), D::ZERO);
2148 let mut v = one;
2150 v += two;
2151 assert_eq!(v, three);
2152 v *= two;
2153 assert_eq!(v, six);
2154 v /= two;
2155 assert_eq!(v, three);
2156 v -= one;
2157 assert_eq!(v, two);
2158 v %= two;
2159 assert_eq!(v, D::ZERO);
2160 let half = D::from_bits(D::multiplier() / crate::wide_int::I256::from_str_radix("2", 10).unwrap());
2162 let one_and_half = one + half;
2163 let product = one_and_half * one_and_half;
2164 let expected = D::from_bits(
2165 D::multiplier() * crate::wide_int::I256::from_str_radix("2", 10).unwrap()
2166 + D::multiplier() / crate::wide_int::I256::from_str_radix("4", 10).unwrap(),
2167 );
2168 assert_eq!(product, expected);
2169 }
2170
2171 #[cfg(any(feature = "d76", feature = "wide"))]
2172 #[test]
2173 fn d76_display() {
2174 type D = super::D76<12>;
2175 let one = D::ONE;
2176 assert_eq!(alloc::format!("{}", one), "1.000000000000");
2177 assert_eq!(alloc::format!("{}", -one), "-1.000000000000");
2178 assert_eq!(alloc::format!("{}", D::ZERO), "0.000000000000");
2179 let half = D::from_bits(D::multiplier() / crate::wide_int::I256::from_str_radix("2", 10).unwrap());
2180 assert_eq!(alloc::format!("{}", half), "0.500000000000");
2181 assert_eq!(alloc::format!("{:?}", one), "D76<12>(1.000000000000)");
2182 let int_only: super::D76<0> = super::D76::<0>::ONE;
2184 assert_eq!(alloc::format!("{}", int_only), "1");
2185 let big = super::D76s75::MAX;
2187 let s = alloc::format!("{}", big);
2188 assert!(s.starts_with("57.8960446"));
2189 assert_eq!(s.len(), "57.".len() + 75);
2190 }
2191
2192 #[cfg(any(feature = "d76", feature = "wide"))]
2193 #[test]
2194 fn d76_sign_and_helpers() {
2195 type D = super::D76<6>;
2196 let neg = -D::ONE;
2197 assert!(neg.is_negative());
2198 assert!(D::ONE.is_positive());
2199 assert!(!D::ZERO.is_positive());
2200 assert_eq!(neg.abs(), D::ONE);
2201 assert_eq!(D::ONE.signum(), D::ONE);
2202 assert_eq!(neg.signum(), neg);
2203 assert_eq!(D::ZERO.signum(), D::ZERO);
2204 let two = D::ONE + D::ONE;
2206 assert_eq!(D::ONE.min(two), D::ONE);
2207 assert_eq!(D::ONE.max(two), two);
2208 assert_eq!(two.clamp(D::ZERO, D::ONE), D::ONE);
2209 assert_eq!(D::ONE.copysign(neg), neg);
2211 assert_eq!(neg.copysign(D::ONE), D::ONE);
2212 let half = D::from_bits(D::multiplier() / crate::wide_int::I256::from_str_radix("2", 10).unwrap());
2214 assert_eq!(two.recip(), half);
2215 }
2216
2217 #[cfg(any(feature = "d76", feature = "wide"))]
2218 #[test]
2219 fn d76_overflow_variants() {
2220 type D = super::D76<2>;
2221 assert_eq!(D::MAX.checked_add(D::ONE), None);
2223 assert_eq!(D::ONE.checked_add(D::ONE), Some(D::ONE + D::ONE));
2224 assert_eq!(D::MAX.saturating_add(D::ONE), D::MAX);
2226 assert_eq!(D::MIN.saturating_sub(D::ONE), D::MIN);
2227 assert_eq!(D::MIN.checked_neg(), None);
2229 assert_eq!(D::ONE.checked_neg(), Some(-D::ONE));
2230 let two = D::ONE + D::ONE;
2232 let three = two + D::ONE;
2233 assert_eq!(two.checked_mul(three), Some(D::from_bits(D::multiplier() * crate::wide_int::I256::from_str_radix("6", 10).unwrap())));
2234 assert_eq!(D::ONE.checked_div(D::ZERO), None);
2235 assert_eq!((three).checked_div(D::ONE), Some(three));
2236 let one_lsb = D::from_bits(crate::wide_int::I256::from_str_radix("1", 10).unwrap());
2238 assert_eq!(D::MAX.wrapping_add(one_lsb), D::MIN);
2239 assert_eq!(D::ONE.overflowing_add(D::ONE), (two, false));
2241 assert_eq!(D::MAX.overflowing_add(D::ONE).1, true);
2242 }
2243
2244 #[cfg(any(feature = "d76", feature = "wide"))]
2245 #[test]
2246 fn d76_consts_and_from_str() {
2247 use crate::types::consts::DecimalConstants;
2248 use core::str::FromStr;
2249 assert_eq!(
2251 super::D76::<12>::pi().to_bits(),
2252 crate::wide_int::I256::from_str_radix("3141592653590", 10).unwrap()
2253 );
2254 assert_eq!(
2255 super::D76::<4>::e().to_bits(),
2256 crate::wide_int::I256::from_str_radix("27183", 10).unwrap()
2257 );
2258 let v = super::D76::<2>::from_str("1.50").unwrap();
2260 assert_eq!(v.to_bits(), crate::wide_int::I256::from_str_radix("150", 10).unwrap());
2261 let neg = super::D76::<2>::from_str("-20.50").unwrap();
2262 assert_eq!(neg.to_bits(), crate::wide_int::I256::from_str_radix("-2050", 10).unwrap());
2263 use ::num_traits::{One, Zero};
2265 assert!(super::D76::<6>::zero().is_zero());
2266 assert!(super::D76::<6>::one().is_one());
2267 }
2268
2269 #[cfg(any(feature = "d76", feature = "wide"))]
2270 #[test]
2271 fn d76_conversions() {
2272 use crate::wide_int::I256;
2273 type D = super::D76<6>;
2274 let from_i32: D = 5i32.into();
2276 assert_eq!(from_i32.to_bits(), I256::from_str_radix("5000000", 10).unwrap());
2277 let from_u64: D = 7u64.into();
2278 assert_eq!(from_u64.to_bits(), I256::from_str_radix("7000000", 10).unwrap());
2279 let from_neg: D = (-3i16).into();
2280 assert_eq!(from_neg.to_bits(), I256::from_str_radix("-3000000", 10).unwrap());
2281 let from_i128 = D::try_from(123i128).unwrap();
2283 assert_eq!(from_i128.to_bits(), I256::from_str_radix("123000000", 10).unwrap());
2284 let from_u128 = D::try_from(u128::MAX).unwrap();
2285 assert_eq!(
2286 from_u128.to_bits(),
2287 I256::from_str_radix("340282366920938463463374607431768211455", 10).unwrap()
2288 * I256::from_str_radix("1000000", 10).unwrap()
2289 );
2290 let from_f64 = D::try_from(2.5f64).unwrap();
2292 assert_eq!(from_f64.to_bits(), I256::from_str_radix("2500000", 10).unwrap());
2293 assert!(D::try_from(f64::NAN).is_err());
2294 assert_eq!(D::from_int(9i128), D::from(9i32));
2296 assert_eq!(D::from_i32(-4), D::from(-4i32));
2297 use crate::support::rounding::RoundingMode;
2299 let two_and_half = D::from_bits(I256::from_str_radix("2500000", 10).unwrap());
2300 assert_eq!(two_and_half.to_int_with(RoundingMode::HalfToEven), 2);
2301 assert_eq!(two_and_half.to_int_with(RoundingMode::HalfAwayFromZero), 3);
2302 assert_eq!(two_and_half.to_int_with(RoundingMode::Ceiling), 3);
2303 assert_eq!(two_and_half.to_int_with(RoundingMode::Floor), 2);
2304 let neg_two_and_half = -two_and_half;
2305 assert_eq!(neg_two_and_half.to_int_with(RoundingMode::Floor), -3);
2306 assert_eq!(neg_two_and_half.to_int_with(RoundingMode::Trunc), -2);
2307 let d38: super::D38s6 = super::D38s6::from_bits(-150);
2309 let widened: super::D76<6> = d38.into();
2310 assert_eq!(widened.to_bits(), I256::from_str_radix("-150", 10).unwrap());
2311 let in_range: super::D76<6> = super::D76::<6>::from_bits(I256::from_str_radix("999", 10).unwrap());
2313 let narrowed: super::D38s6 = in_range.try_into().unwrap();
2314 assert_eq!(narrowed.to_bits(), 999i128);
2315 let out_of_range = super::D76s75::MAX;
2317 let narrow_fail: Result<super::D38<75>, _> = out_of_range.try_into();
2318 assert!(narrow_fail.is_err());
2319 }
2320
2321 #[cfg(any(feature = "d76", feature = "wide"))]
2322 #[test]
2323 fn d76_rescale_rounding_floats() {
2324 use crate::support::rounding::RoundingMode;
2325 use crate::wide_int::I256;
2326 type D6 = super::D76<6>;
2327 let v = D6::from_bits(I256::from_str_radix("1500000", 10).unwrap()); let up: super::D76<9> = v.rescale::<9>();
2330 assert_eq!(up.to_bits(), I256::from_str_radix("1500000000", 10).unwrap());
2331 let down: super::D76<2> = v.rescale::<2>();
2333 assert_eq!(down.to_bits(), I256::from_str_radix("150", 10).unwrap());
2334 let two_p_five = super::D76::<1>::from_bits(I256::from_str_radix("25", 10).unwrap());
2336 let r0: super::D76<0> = two_p_five.rescale_with::<0>(RoundingMode::HalfToEven);
2337 assert_eq!(r0.to_bits(), I256::from_str_radix("2", 10).unwrap());
2338 let r0b: super::D76<0> = two_p_five.rescale_with::<0>(RoundingMode::HalfAwayFromZero);
2339 assert_eq!(r0b.to_bits(), I256::from_str_radix("3", 10).unwrap());
2340 assert_eq!(v.floor(), D6::ONE);
2342 assert_eq!(v.ceil(), D6::ONE + D6::ONE);
2343 assert_eq!(v.round(), D6::ONE + D6::ONE); assert_eq!(v.trunc(), D6::ONE);
2345 assert_eq!(v.fract(), D6::from_bits(I256::from_str_radix("500000", 10).unwrap()));
2346 let neg = -v;
2348 assert_eq!(neg.floor(), -(D6::ONE + D6::ONE));
2349 assert_eq!(neg.ceil(), -D6::ONE);
2350 assert_eq!(neg.round(), -(D6::ONE + D6::ONE));
2351 let from_f = D6::from_f64(2.5);
2353 assert_eq!(from_f.to_bits(), I256::from_str_radix("2500000", 10).unwrap());
2354 assert_eq!(D6::from_f64(f64::NAN), D6::ZERO);
2355 assert_eq!(D6::from_f64(f64::INFINITY), D6::MAX);
2356 let round_trip = D6::ONE.to_f64();
2357 assert!((round_trip - 1.0).abs() < 1e-9);
2358 }
2359
2360 #[cfg(any(feature = "d153", feature = "wide"))]
2361 #[test]
2362 fn d153_smoke() {
2363
2364 use crate::types::traits::arithmetic::DecimalArithmetic;
2365 use crate::wide_int::I512;
2366 type D = super::D153<35>;
2367 assert_eq!(<D as DecimalArithmetic>::MAX_SCALE, 152);
2368 assert_eq!(D::ZERO.to_bits(), I512::from_str_radix("0", 10).unwrap());
2369 let one = D::ONE;
2370 let two = one + one;
2371 let three = two + one;
2372 assert_eq!(two * three, D::from_int(6i128));
2373 assert_eq!((three * two) / two, three);
2374 assert_eq!(alloc::format!("{}", one).len(), "1.".len() + 35);
2375 assert_eq!(D::from_int(5i128).to_int(), 5);
2376 let up: super::D153<150> = one.rescale::<150>();
2378 assert_eq!(up, super::D153::<150>::ONE);
2379 let _ = super::D153s152::multiplier();
2381 }
2382
2383 #[cfg(any(feature = "d307", feature = "wide"))]
2384 #[test]
2385 fn d307_smoke() {
2386
2387 use crate::types::traits::arithmetic::DecimalArithmetic;
2388 use crate::wide_int::I1024;
2389 type D = super::D307<35>;
2390 assert_eq!(<D as DecimalArithmetic>::MAX_SCALE, 306);
2391 let one = D::ONE;
2392 let two = one + one;
2393 let three = two + one;
2394 assert_eq!(two * three, D::from_int(6i128));
2395 assert_eq!((three * two) / two, three);
2396 assert_eq!(D::ZERO.to_bits(), I1024::from_str_radix("0", 10).unwrap());
2397 assert_eq!(alloc::format!("{}", one).len(), "1.".len() + 35);
2398 #[cfg(any(feature = "d76", feature = "wide"))]
2400 {
2401 let small: super::D76<35> = super::D76::<35>::ONE;
2402 let widened: super::D307<35> = small.into();
2403 assert_eq!(widened, D::ONE);
2404 let narrowed: super::D76<35> = widened.try_into().unwrap();
2405 assert_eq!(narrowed, super::D76::<35>::ONE);
2406 }
2407 let _ = super::D307s306::multiplier();
2409 }
2410
2411 #[test]
2412 fn d9_op_assign() {
2413 let mut v = super::D9s2::from_bits(100);
2414 v += super::D9s2::from_bits(50);
2415 assert_eq!(v.to_bits(), 150);
2416 v -= super::D9s2::from_bits(25);
2417 assert_eq!(v.to_bits(), 125);
2418 v *= super::D9s2::from_bits(200); assert_eq!(v.to_bits(), 250);
2420 v /= super::D9s2::from_bits(200); assert_eq!(v.to_bits(), 125);
2422 v %= super::D9s2::from_bits(100);
2423 assert_eq!(v.to_bits(), 25);
2424 }
2425}