Skip to content

Commit

Permalink
Simplify FixedDecimal's rounding APIs (#5028)
Browse files Browse the repository at this point in the history
Related to #2902

Mainly removes all the `_to_increment` methods, which are superseeded by
the `round_with_mode_and_increment` method.

Additionally, adds a `round` function that does half to even rounding.
  • Loading branch information
jedel1043 committed Jun 26, 2024
1 parent 8e7e8e7 commit cdd447e
Show file tree
Hide file tree
Showing 24 changed files with 1,580 additions and 2,192 deletions.
4 changes: 2 additions & 2 deletions components/experimental/src/compactdecimal/compactdecimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,11 @@ impl CompactDecimalFormatter {
// If we have just one digit before the decimal point…
if significand.nonzero_magnitude_start() == 0 {
// …round to one fractional digit…
significand.half_even(-1);
significand.round(-1);
} else {
// …otherwise, we have at least 2 digits before the decimal point,
// so round to eliminate the fractional part.
significand.half_even(0);
significand.round(0);
}
let rounded_magnitude = significand.nonzero_magnitude_start() + i16::from(exponent);
if rounded_magnitude > log10_type {
Expand Down
33 changes: 6 additions & 27 deletions ffi/capi/bindings/c/ICU4XFixedDecimal.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions ffi/capi/bindings/c/ICU4XFixedDecimalRoundingMode.d.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions ffi/capi/bindings/c/ICU4XFixedDecimalRoundingMode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 7 additions & 27 deletions ffi/capi/bindings/cpp/ICU4XFixedDecimal.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 18 additions & 100 deletions ffi/capi/bindings/cpp/ICU4XFixedDecimal.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cdd447e

Please sign in to comment.