Skip to content

Conversation

@chiphogg
Copy link
Member

This adds one (templated) type for each of various kinds of truncation
risk that we might have. Each type has a would_value_truncate(T)
member, which assesses any individual value of type T to see if it
would truncate. Future PRs will associate each operation with one of
these.

This set isn't perfect. In particular, I'm pretty suspicious as to
whether ValueTimesRatioIsNotInteger is the right solution. But in my
local client, this suite seems to be able to handle all the cases I
checked. I think the most important thing is the structure. If we
land a suite that passes all known test cases, then we can clean up the
particular details later on, and trust in our expanding set of test
cases to be sure we end up in a better place.

Helps #349. Technically, that's only about overflow, but we can't
actually use the new overflow implementations without moving to this
operation based approach, which means we need to be able to handle
truncation too. Besides, this will ultimately lead to more efficient
truncation checkers as well.

chiphogg added 2 commits July 16, 2025 10:07
This adds one (templated) type for each of various kinds of truncation
risk that we might have.  Each type has a `would_value_truncate(T)`
member, which assesses _any individual value_ of type `T` to see if it
would truncate.  Future PRs will associate each operation with one of
these.

This set isn't perfect.  In particular, I'm pretty suspicious as to
whether `ValueTimesRatioIsNotInteger` is the right solution.  But in my
local client, this suite seems to be able to handle all the cases I
checked.  I think **the most important thing is the structure**.  If we
land a suite that passes all known test cases, then we can clean up the
particular details later on, and trust in our expanding set of test
cases to be sure we end up in a better place.

Helps #349.  Technically, that's only about overflow, but we can't
actually _use_ the new overflow implementations without moving to this
operation based approach, which means we need to be able to handle
truncation too.  Besides, this will ultimately lead to more efficient
truncation checkers as well.
@chiphogg chiphogg merged commit 30da24a into main Jul 17, 2025
14 checks passed
@chiphogg chiphogg deleted the chiphogg/trunc-risk-would-val-trunc#349 branch July 17, 2025 20:05
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.

3 participants