Skip to content

Implement round built-in function #199

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

Merged
merged 7 commits into from
Mar 6, 2022
Merged

Conversation

namannimmo10
Copy link
Collaborator

@namannimmo10 namannimmo10 commented Mar 4, 2022

We can implement a generic round once overload is supported in LPython (#187), but for now this works for float arguments.

TODO:

  • fix the case when the compile-time value is 0.5 (Outputs with Python and C++ are different: 0 and 1 respectively)

@certik
Copy link
Contributor

certik commented Mar 4, 2022

Looks good so far.

@namannimmo10
Copy link
Collaborator Author

Gives garbage values for the 6 print statements:

1075230278
1090940434
1078307718
1071644672
1078575105
1071644672

I think that's because we are calling other built-in functions in our current runtime implementation.

@certik
Copy link
Contributor

certik commented Mar 4, 2022

I usually get the function (round in this case) working first in a simple script. Then put it into the runtime library.

@namannimmo10
Copy link
Collaborator Author

OK, this is ready for now; let me know if you have any suggestions or I'll merge this. Generic versions of these built-in functions will be added soon.

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

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

I think this looks great!

@certik certik merged commit e709f9f into lcompilers:main Mar 6, 2022
@namannimmo10 namannimmo10 deleted the round branch March 6, 2022 05:44
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.

2 participants