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

Fixed #33464 -- Resolved output_field for combined numeric expressions with MOD operator. #16082

Merged
merged 1 commit into from Sep 27, 2022

Conversation

David-Wobrock
Copy link
Member

@David-Wobrock David-Wobrock commented Sep 21, 2022

ticket-33464

I'm unsure about the second commit, if it makes sense to define as default FloatField + DecimalField => DecimalField.
I'd say that one wants to keep the decimal precision by default, like when doing plain Python arithmetic with a Decimal.

@David-Wobrock David-Wobrock changed the title Fixed #33464 - Defined MOD operator output_field for combined numeric expressions. Fixed #33464 -- Defined MOD operator output_field for combined numeric expressions. Sep 21, 2022
@David-Wobrock David-Wobrock marked this pull request as ready for review September 23, 2022 10:12
@felixxm
Copy link
Member

felixxm commented Sep 27, 2022

@David-Wobrock Thanks 👍 I think we should drop the second commit as we will lose precision anyway and users should be aware of that, e.g:

SQL> SELECT MOD(4.6, TO_BINARY_FLOAT(2.5)) FROM DUAL;

MOD(4.6,TO_BINARY_FLOAT(2.5))
-----------------------------
		     2.1E+000

SQL> SELECT CAST(MOD(4.6, TO_BINARY_FLOAT(2.5)) AS NUMBER) FROM DUAL;

CAST(MOD(4.6,TO_BINARY_FLOAT(2.5))ASNUMBER)
-------------------------------------------
				  2.0999999

SQL> SELECT MOD(4.6, 2.5) FROM DUAL;

MOD(4.6,2.5)
------------
	 2.1

@David-Wobrock
Copy link
Member Author

Ah yes @felixxm , that's the caveat I missed. I removed the second commit, thanks 🙏

@felixxm felixxm changed the title Fixed #33464 -- Defined MOD operator output_field for combined numeric expressions. Fixed #33464 -- Resolved output_field for combined numeric expressions with MOD operator. Sep 27, 2022
@felixxm felixxm merged commit cff1f88 into django:main Sep 27, 2022
@felixxm
Copy link
Member

felixxm commented Sep 27, 2022

@David-Wobrock Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants