Skip to content

Conversation

owljoa
Copy link
Contributor

@owljoa owljoa commented Sep 11, 2021

add conditions for below rules (specified in test codes)

  1. remainder(x, inf) is x, for non-NaN non-infinite x
  2. According to IEEE 754-2008 7.2(f)
    2-1. remainder(x, 0) for non-NaN x is invalid operation
    2-2. remainder(infinity, x) for non-NaN x is invalid operation

add conditions for below rules

1. remainder(x, inf) is x, for non-NaN non-infinite x
2. According to IEEE 754-2008 7.2(f)
 2-1. remainder(x, 0) for non-NaN x is invalid operation
 2-2. remainder(infinity, x) for non-NaN x is invalid operation
Co-authored-by: Jim Fasarakis-Hilliard <d.f.hilliard@gmail.com>
@owljoa owljoa requested a review from DimitrisJim September 11, 2021 14:11
Copy link
Member

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm now.

I'm under the impression a similar set of checks is done for other functions too (looking through the CPython code FUNC_2 wraps many (double, double) -> double funcs). Don't know what the other functions in math.rs do currently but I'm guessing there's lots of duplicated code checking these same edge cases.

Not requesting this now, it just seems like a good refactoring opportunity if you'd be interested.

@youknowone
Copy link
Member

I think we need a utility for "math domain error". it appears everywhere.

@youknowone youknowone merged commit dcc8043 into RustPython:main Sep 11, 2021
@owljoa owljoa deleted the fix-math-remainder-test branch September 12, 2021 05:37
@youknowone youknowone added the z-ca-2021 Tag to track contrubution-academy 2021 label Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
z-ca-2021 Tag to track contrubution-academy 2021
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants