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 Ratio type #423

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Add Ratio type #423

wants to merge 21 commits into from

Conversation

GreasySlug
Copy link
Member

@GreasySlug GreasySlug commented Apr 27, 2023

Fixes #218.

Changes proposed in this PR:

  • Add Ratio type

    • Add ratio.rs
      • add
      • sub
      • div
      • rem
      • mul
      • eq
      • PartialEq
    • Add _erg_ratio.py
      • Ratio class
      • RatioMut class
      • Ratio.d.er
  • TODO

    • integration tests
    • declare of Float type

Removed

These contents are excluded

  • Add Complex type
    • Implement complex type by using ratio.rs
    • Add _erg_complex.py
    • Add ComplexLit, Im token
    • parse Im token
    • convert Im token and num calc to ComplexLit
  • Improve Int, Nat, Bool type

Currently known bugs

  • import "consts"
    infinite loop? or so long runtime
  • tests/should_ok/structural.er
  • mut_array.er
  • Cannot define Float type
  • print! 0.3
    runtime is 3/10 but test code eval is 0.3

@mtshiba

@GreasySlug GreasySlug changed the title [WIP] Add Ratio type Add Ratio type Aug 25, 2024
@GreasySlug GreasySlug marked this pull request as ready for review August 25, 2024 15:39
@mtshiba mtshiba self-requested a review August 26, 2024 04:26
@mtshiba
Copy link
Member

mtshiba commented Aug 26, 2024

The display of rational numbers is not consistent. It would be better to display them in the form numerator/denominator (e.g. 3/10).

>>> 3/10
Ratio(3, 10)
>>> 0.3
(3, 10)
>>> 2.3 % 2
Fraction(3, 10)

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

Successfully merging this pull request may close these issues.

Define Ratio(Complex) type
2 participants