1212use crate :: num:: dec2flt:: common:: { ByteSlice , is_8digits} ;
1313
1414#[ derive( Clone ) ]
15- pub struct Decimal {
15+ pub ( super ) struct Decimal {
1616 /// The number of significant digits in the decimal.
1717 pub num_digits : usize ,
1818 /// The offset of the decimal point in the significant digits.
@@ -55,21 +55,21 @@ impl Decimal {
5555 ///
5656 /// In Python:
5757 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
58- pub const MAX_DIGITS : usize = 768 ;
58+ pub ( super ) const MAX_DIGITS : usize = 768 ;
5959 /// The max digits that can be exactly represented in a 64-bit integer.
60- pub const MAX_DIGITS_WITHOUT_OVERFLOW : usize = 19 ;
61- pub const DECIMAL_POINT_RANGE : i32 = 2047 ;
60+ pub ( super ) const MAX_DIGITS_WITHOUT_OVERFLOW : usize = 19 ;
61+ pub ( super ) const DECIMAL_POINT_RANGE : i32 = 2047 ;
6262
6363 /// Append a digit to the buffer.
64- pub fn try_add_digit ( & mut self , digit : u8 ) {
64+ pub ( super ) fn try_add_digit ( & mut self , digit : u8 ) {
6565 if self . num_digits < Self :: MAX_DIGITS {
6666 self . digits [ self . num_digits ] = digit;
6767 }
6868 self . num_digits += 1 ;
6969 }
7070
7171 /// Trim trailing zeros from the buffer.
72- pub fn trim ( & mut self ) {
72+ pub ( super ) fn trim ( & mut self ) {
7373 // All of the following calls to `Decimal::trim` can't panic because:
7474 //
7575 // 1. `parse_decimal` sets `num_digits` to a max of `Decimal::MAX_DIGITS`.
@@ -83,7 +83,7 @@ impl Decimal {
8383 }
8484 }
8585
86- pub fn round ( & self ) -> u64 {
86+ pub ( super ) fn round ( & self ) -> u64 {
8787 if self . num_digits == 0 || self . decimal_point < 0 {
8888 return 0 ;
8989 } else if self . decimal_point > 18 {
@@ -111,7 +111,7 @@ impl Decimal {
111111 }
112112
113113 /// Computes decimal * 2^shift.
114- pub fn left_shift ( & mut self , shift : usize ) {
114+ pub ( super ) fn left_shift ( & mut self , shift : usize ) {
115115 if self . num_digits == 0 {
116116 return ;
117117 }
@@ -152,7 +152,7 @@ impl Decimal {
152152 }
153153
154154 /// Computes decimal * 2^-shift.
155- pub fn right_shift ( & mut self , shift : usize ) {
155+ pub ( super ) fn right_shift ( & mut self , shift : usize ) {
156156 let mut read_index = 0 ;
157157 let mut write_index = 0 ;
158158 let mut n = 0_u64 ;
@@ -202,7 +202,7 @@ impl Decimal {
202202}
203203
204204/// Parse a big integer representation of the float as a decimal.
205- pub fn parse_decimal ( mut s : & [ u8 ] ) -> Decimal {
205+ pub ( super ) fn parse_decimal ( mut s : & [ u8 ] ) -> Decimal {
206206 let mut d = Decimal :: default ( ) ;
207207 let start = s;
208208
0 commit comments