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

Numeric Casting Operations #361

Merged
merged 18 commits into from
Jun 3, 2024
Merged

Numeric Casting Operations #361

merged 18 commits into from
Jun 3, 2024

Conversation

enricozb
Copy link
Contributor

@enricozb enricozb commented May 29, 2024

Adds support for numeric casting operations, [u24], [i24], [f24].

Fixes #322.

Casts are always defined, and spiritually follow rusts numeric casting semantics:

  • i24 <-> u24 is just reinterpretation of bits.
  • f24 -> i24 or f24 -> u24 casts to the "closest" integer representing this float, saturating if out of range and 0 if NaN.
  • i24 -> f24 or u24 -> f24 casts to the "closest" float representing this integer.

@enricozb enricozb changed the base branch from main to enricozb/print-num May 29, 2024 11:06
@enricozb enricozb marked this pull request as ready for review May 29, 2024 11:07
@enricozb enricozb requested review from VictorTaelin and tjjfvi and removed request for VictorTaelin May 29, 2024 11:07
@enricozb enricozb force-pushed the enricozb/cast-num branch from fdc174e to 3853c69 Compare May 29, 2024 11:52
Base automatically changed from enricozb/print-num to main May 29, 2024 15:59
@enricozb enricozb requested a review from VictorTaelin May 30, 2024 05:51
src/ast.rs Outdated Show resolved Hide resolved
src/hvm.rs Outdated Show resolved Hide resolved
src/hvm.rs Outdated Show resolved Hide resolved
@@ -4,6 +4,6 @@ expression: rust_output
input_file: tests/programs/empty.hvm
---
exit status: 101
thread 'main' panicked at src/ast.rs:508:41:
thread 'main' panicked at src/ast.rs:527:41:
Copy link
Contributor

Choose a reason for hiding this comment

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

off-topic but this diff is pretty annoying; we should figure out a better way to test this

@enricozb enricozb requested a review from tjjfvi May 31, 2024 04:23
@enricozb enricozb merged commit f158106 into main Jun 3, 2024
3 of 4 checks passed
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.

Numeric Type Conversion
2 participants