@@ -197,32 +197,29 @@ pub fn rules_numbers(b: &mut RuleSetBuilder<Dimension>) -> RustlingResult<()> {
197197 FloatValue :: new ( value)
198198 } ) ;
199199 b. rule_3 ( "number dot number" ,
200- number_check ! ( |number : & NumberValue | !number . prefixed( ) ) ,
200+ integer_check ! ( |integer : & IntegerValue | !integer . prefixed) ,
201201 b. reg ( r#"punto|virgola"# ) ?,
202- number_check ! ( |number : & NumberValue | !number . suffixed( ) ) ,
202+ integer_check ! ( |integer : & IntegerValue | !integer . suffixed) ,
203203 |a, _, b| {
204- let power = b. value ( ) . value ( ) . to_string ( ) . chars ( ) . count ( ) ;
205- let coeff = 10.0_f64 . powf ( -1.0 * power as f64 ) ;
204+ let value: f64 = format ! ( "{}.{}" , a. value( ) . value, b. value( ) . value) . parse ( ) ?;
206205 Ok ( FloatValue {
207- value : b . value ( ) . value ( ) * coeff + a . value ( ) . value ( ) ,
206+ value,
208207 ..FloatValue :: default ( )
209208 } )
210209 } ) ;
211-
212210 b. rule_4 ( "number dot zero ... number" ,
213- number_check ! ( |number : & NumberValue | !number . prefixed( ) ) ,
211+ integer_check ! ( |integer : & IntegerValue | !integer . prefixed) ,
214212 b. reg ( r#"punto|virgola"# ) ?,
215213 b. reg ( r#"(?:(?:zero )*(?:zero))"# ) ?,
216- number_check ! ( |number : & NumberValue | !number . suffixed( ) ) ,
214+ integer_check ! ( |integer : & IntegerValue | !integer . suffixed) ,
217215 |a, _, zeros, b| {
218- let power = zeros. group ( 0 ) . split_whitespace ( ) . count ( ) + b . value ( ) . value ( ) . to_string ( ) . chars ( ) . count ( ) ;
219- let coeff = 10.0_f64 . powf ( - 1.0 * power as f64 ) ;
216+ let zeros_string = std :: iter :: repeat ( "0" ) . take ( zeros. group ( 0 ) . split_whitespace ( ) . count ( ) ) . collect :: < String > ( ) ;
217+ let value : f64 = format ! ( "{}.{}{}" , a . value ( ) . value , zeros_string , b . value ( ) . value ) . parse ( ) ? ;
220218 Ok ( FloatValue {
221- value : b . value ( ) . value ( ) * coeff + a . value ( ) . value ( ) ,
219+ value,
222220 ..FloatValue :: default ( )
223221 } )
224222 } ) ;
225-
226223 b. rule_1_terminal ( "decimal with thousands separator" ,
227224 b. reg ( r#"(\d+(\.\d\d\d)+,\d+)"# ) ?,
228225 |text_match| {
0 commit comments