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

Parse Floating Point Constants #2195

Open
wants to merge 2 commits into
base: calyx-float
Choose a base branch
from

Conversation

jiahanxie353
Copy link
Collaborator

This PR tries to address #2061
Support:

  1. parsing of floating point in the frontend and
  2. the conversion between "human-readable" decimal representation of floating point numbers and IEEE754 representation for json/data files.

},
"mem_write": {
"data": [
4.2
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh the second thought is that it only proves that it reads/writes the same value, but doesn't prove that it's not necessarily intepretting 4.2 as the decimal representation..

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain what you mean by that? The comment is lacking enough context to make sense to me.

@@ -26,7 +27,8 @@ num_lit = ${
~ ( "d" ~ decimal
| "b" ~ binary
| "x" ~ hex
| "o" ~ octal )
| "o" ~ octal
| "f" ~ float)
Copy link
Contributor

Choose a reason for hiding this comment

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

One challenging thing about this is that we are hardcoding IEEE-754 encoding for floating point and might eventually want to support things like posits (something that @Mark1626 was working on) so we might want a different way to specify floating point numbers?

@sampsyo thoughts? One thing I was thinking is that the syntax is only available in a magical primitive:

cf1 = ieee754_const(5.11231); // Error if exact representation is not possible

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.

None yet

2 participants