Skip to content

Conversation

cqc-alec
Copy link
Collaborator

Turns out the implementation in the constant-folding code is already in line with this modified specification, so this is not a breaking change.

Closes #771 .

@cqc-alec cqc-alec requested a review from ss2165 April 12, 2024 14:16
@cqc-alec cqc-alec marked this pull request as ready for review April 12, 2024 14:16
Copy link
Member

@ss2165 ss2165 left a comment

Choose a reason for hiding this comment

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

thanks!

@cqc-alec
Copy link
Collaborator Author

Hmm I may have been a bit hasty -- it looks like rust (at least by default, since 1.45) performs "float-type as integer-type" conversions according to a bunch of rules that include sending non-finite and NaN values to well-defined values, so the implementation is not quite in line with the spec. rust-lang/rust#71269
In two minds as to which way to go.

@cqc-alec
Copy link
Collaborator Author

There's a good summary on that PR of what other languages do, which is quite variable, but I tend to agree with the author's comment that "overall rounding to zero and saturation is the common case", so am inclined to modify the spec accordingly. (This would mean these functions could not produce an error.)

@cqc-alec
Copy link
Collaborator Author

Was misreading the code. There is a check for finiteness. The only edge case remaining is casting a negative float to an unsigned; this will result in 0, which I think is adequately described by "rounding towards zero".

@cqc-alec cqc-alec added this pull request to the merge queue Apr 12, 2024
Merged via the queue into main with commit a4db014 Apr 12, 2024
@cqc-alec cqc-alec deleted the bugfix/trunc branch April 12, 2024 14:55
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.

Fix definitions of trunc_u and trunc_s

2 participants