@@ -178,6 +178,8 @@ public NumberRangeFormatterImpl(RangeMacroProps macros) {
178178 }
179179
180180 public FormattedNumberRange format (DecimalQuantity quantity1 , DecimalQuantity quantity2 , boolean equalBeforeRounding ) {
181+ DecimalQuantity quantityBackup = quantity1 .createCopy ();
182+
181183 FormattedStringBuilder string = new FormattedStringBuilder ();
182184 MicroProps micros1 = formatterImpl1 .preProcess (quantity1 );
183185 MicroProps micros2 ;
@@ -224,7 +226,7 @@ public FormattedNumberRange format(DecimalQuantity quantity1, DecimalQuantity qu
224226 case (2 | (1 << 4 )): // APPROXIMATELY, EQUAL_AFTER_ROUNDING
225227 case (2 | (0 << 4 )): // APPROXIMATELY, EQUAL_BEFORE_ROUNDING
226228 case (1 | (1 << 4 )): // APPROXIMATE_OR_SINGLE_VALUE, EQUAL_AFTER_ROUNDING
227- formatApproximately (quantity1 , quantity2 , string , micros1 , micros2 );
229+ formatApproximately (quantityBackup , quantity1 , quantity2 , string , micros1 , micros2 );
228230 break ;
229231
230232 case (1 | (0 << 4 )): // APPROXIMATE_OR_SINGLE_VALUE, EQUAL_BEFORE_ROUNDING
@@ -252,13 +254,12 @@ private void formatSingleValue(DecimalQuantity quantity1, DecimalQuantity quanti
252254
253255 }
254256
255- private void formatApproximately (DecimalQuantity quantity1 , DecimalQuantity quantity2 , FormattedStringBuilder string ,
257+ private void formatApproximately (DecimalQuantity quantityBackup , DecimalQuantity quantity1 , DecimalQuantity quantity2 , FormattedStringBuilder string ,
256258 MicroProps micros1 , MicroProps micros2 ) {
257259 if (fSameFormatters ) {
258260 // Re-format using the approximately formatter:
259- quantity1 .resetExponent ();
260- MicroProps microsAppx = fApproximatelyFormatter .preProcess (quantity1 );
261- int length = NumberFormatterImpl .writeNumber (microsAppx , quantity1 , string , 0 );
261+ MicroProps microsAppx = fApproximatelyFormatter .preProcess (quantityBackup );
262+ int length = NumberFormatterImpl .writeNumber (microsAppx , quantityBackup , string , 0 );
262263 // HEURISTIC: Desired modifier order: inner, middle, approximately, outer.
263264 length += microsAppx .modInner .apply (string , 0 , length );
264265 length += microsAppx .modMiddle .apply (string , 0 , length );
0 commit comments