File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,13 @@ use dashu_int::IBig;
77use once_cell:: sync:: Lazy ;
88use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
99
10- pub static PREC_BITS : AtomicUsize = AtomicUsize :: new ( 1000 ) ;
10+ const PREC_BITS_INITIAL : usize = 1000 ;
11+ pub static PREC_BITS : AtomicUsize = AtomicUsize :: new ( PREC_BITS_INITIAL ) ;
12+
13+ // Reset precision to the initial value
14+ pub fn reset_prec_bits ( ) {
15+ PREC_BITS . store ( PREC_BITS_INITIAL , Ordering :: Relaxed ) ;
16+ }
1117
1218pub fn set_prec_bits ( bits : usize ) {
1319 PREC_BITS . store ( bits, Ordering :: Relaxed ) ;
Original file line number Diff line number Diff line change 11use crate :: common:: ib_to_bf_prec;
2- use crate :: common:: set_prec_bits;
2+ use crate :: common:: { reset_prec_bits , set_prec_bits} ;
33use dashu_float:: round:: mode:: HalfEven ;
44use dashu_float:: FBig ;
55use dashu_int:: { IBig , UBig } ;
@@ -77,6 +77,12 @@ pub fn config_from_theta_epsilon(
7777 verbose : bool ,
7878) -> GridSynthConfig {
7979 let ( theta_num, theta_den) = parse_decimal_with_exponent ( & theta. to_string ( ) ) . unwrap ( ) ;
80+
81+ // The desired floating precision is initialized in module common.
82+ // It has the initial value the first time this function is called.
83+ // But, on subsequent calls, the precision has changed.
84+ // We reset it so that the precison is the same at the beginning of every synthesis.
85+ reset_prec_bits ( ) ;
8086 let theta = ib_to_bf_prec ( theta_num) / ib_to_bf_prec ( theta_den) ;
8187 let ( epsilon_num, epsilon_den) = parse_decimal_with_exponent ( & epsilon. to_string ( ) ) . unwrap ( ) ;
8288 // The magic number 12 safely overapproximates the bits of precision.
You can’t perform that action at this time.
0 commit comments