Skip to content

fix sbb subtracting 2^64#86

Open
andres-erbsen wants to merge 1 commit intomainfrom
andreser/fix-unsigned-underflow
Open

fix sbb subtracting 2^64#86
andres-erbsen wants to merge 1 commit intomainfrom
andreser/fix-unsigned-underflow

Conversation

@andres-erbsen
Copy link
Copy Markdown
Collaborator

@andres-erbsen andres-erbsen commented Apr 17, 2026

UInt64.toInt returns a non-negative number
BitVec.toInt returns may return a negative number
BitVec.toNat returns a Nat which has saturating subtraction

Let's stick with the Rocq convention of .unsigned and .signed for fixed-width variables, both returning Int

h/t @miriampolzer for asking me about this code

@protz
Copy link
Copy Markdown
Collaborator

protz commented Apr 20, 2026

Saturating Nat subtraction always trips us, so I'm in support of this. What's up with take vs truncate?

@andres-erbsen
Copy link
Copy Markdown
Collaborator Author

They're the same function, just take doesn't make me go and look up which end is being truncated. I can put truncate back if you prefer it, or we could do something like truncLsb.

Copy link
Copy Markdown
Collaborator

@protz protz left a comment

Choose a reason for hiding this comment

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

I like the consistency. Good for me 👍

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