ion-rust icon indicating copy to clipboard operation
ion-rust copied to clipboard

Functions in Decimal and Coefficient with misleading behavior

Open rmarrowstone opened this issue 2 years ago • 2 comments

There are two crate-visible functions in Decimal and Coefficient that are used for timestamps.

To support that there are two functions which work fine for their current purposes but have surprising semantics on their own:

  • Coefficient::number_of_decimal_digits() does not consider the sign
  • Decimal::is_greater_than_or_equal_to_one() returns true for n <= -1

rmarrowstone avatar Sep 27 '22 00:09 rmarrowstone

An observation is that the TimestampBuilder could be refactored to take the components of the Decimal for fractional seconds. This would preserve the invariants such that the Text parser and DOM instantiation code couldn't get a runtime error. The binary parser is where the invariants needs to be checked at runtime, but we can put the checks there on the raw values that make up the Decimal.

rmarrowstone avatar Sep 27 '22 00:09 rmarrowstone

The methods mentioned are not public, so I don't think this needs to block 1.0.

zslayton avatar Jul 05 '23 19:07 zslayton