Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Decimal128 #1192

Merged
merged 30 commits into from
May 16, 2023
Merged

Add Decimal128 #1192

merged 30 commits into from
May 16, 2023

Conversation

nielsenko
Copy link
Contributor

@nielsenko nielsenko commented Mar 2, 2023

Add support for Decimal128. This behaves as you would expect from IEEE754, including behaviour of NaN comparison, ie. Nan == NaN is false. Note that you can still query for a NaN value in the DB as realm-core treats NaN as any other (single) value, to have a total order.

Be aware that the Dart compareTo method is implemented to honor the total ordering of IEEE754-2008 paragraf 5.10, which mimic the behaviour of Dart double. Note that this means that compareTo will order any values, including +/- NaN, +/- Infinity as well as +/- 0. This implies the compareTo operation is different from the partial ordering given by operator==, operator<, and operator>. For example, IEEE doubles impose that Decimal128.zero == -Decimal128.zero and all comparison operations on NaN return false.

This function imposes a complete ordering for doubles. When using compareTo, the following properties hold:

  • All NaN values are considered equal, and greater than any numeric value.
  • -Decimal128.zero is less than Decimal128.zero (and the integer 0), but greater than any non-zero negative value.
  • Negative infinity is less than all other values and positive infinity is greater than all non-NaN values.
  • All other values are compared using their numeric value.

@cla-bot cla-bot bot added the cla: yes label Mar 2, 2023
@nielsenko nielsenko force-pushed the kn/decimal128 branch 2 times, most recently from b55fc9a to bd68e97 Compare March 2, 2023 14:40
@dotjon0
Copy link

dotjon0 commented Mar 2, 2023

so pleased this is in motion @nielsenko , thank you soooo much!

@nielsenko
Copy link
Contributor Author

@dotjon0 I will need to postpone this work about a week, but then I'll return to it. I hope it is not inconvenient.

Note that it is a fairly rudimentary implementation supporting just basic the arithmetic operations (+,-,*,/, and abs())and the ability to convert to from int, double, and String.

@dotjon0
Copy link

dotjon0 commented Mar 5, 2023

@dotjon0 I will need to postpone this work about a week, but then I'll return to it. I hope it is not inconvenient.

Note that it is a fairly rudimentary implementation supporting just basic the arithmetic operations (+,-,*,/, and abs())and the ability to convert to from int, double, and String.

@nielsenko no need to apologise, we are just very grateful for this feature going in! Functionality sounds great. Thank you so much

@coveralls
Copy link

coveralls commented Apr 11, 2023

Pull Request Test Coverage Report for Build 4991375873

  • 65 of 69 (94.2%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 88.972%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/src/native/realm_core.dart 14 16 87.5%
lib/src/realm_object.dart 0 2 0.0%
Totals Coverage Status
Change from base Build 4977863642: 0.2%
Covered Lines: 3098
Relevant Lines: 3482

💛 - Coveralls

@nielsenko nielsenko force-pushed the kn/decimal128 branch 3 times, most recently from 5251e23 to 0413522 Compare April 12, 2023 05:21
@nielsenko nielsenko marked this pull request as ready for review April 14, 2023 07:13
@nielsenko nielsenko force-pushed the kn/decimal128 branch 4 times, most recently from b8a87d6 to 08cc103 Compare April 14, 2023 12:22
@nielsenko nielsenko marked this pull request as draft April 14, 2023 14:13
@nielsenko nielsenko marked this pull request as ready for review April 18, 2023 15:29
@nielsenko nielsenko force-pushed the kn/decimal128 branch 4 times, most recently from dfb9a3a to 86badfb Compare April 20, 2023 14:43
src/realm_dart.cpp Outdated Show resolved Hide resolved
@nielsenko nielsenko merged commit 5cc86e2 into main May 16, 2023
@nielsenko nielsenko deleted the kn/decimal128 branch May 16, 2023 12:29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants