-
Notifications
You must be signed in to change notification settings - Fork 0
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
Making ostime_t unsigned? #12
Comments
Exactly. I've also seen this happen in practice, though I've not seen any breakage yet (I suspect that in most cases the compiler would use this to ensure that it can just use plain addition and subtraction instructions without worrying about overflow, and those instructions typically just do the right thing for our usecase. Things are more tricky when multiplication and/or division is involved, but we don't really use those in a way that overflows anyway).
Good point, hadn't realized that. But in practice, all implementations chose 2-complements, I guess, so that should be guaranteed to work properly on all implementations that we'd actually use.
That's a good point, I hadn't thought about use of the type outside of BM itself. Renaming the type might not actually be enough to compile-break such application code, i.e. subtracting the result of two functions that (now) return an
Looks nice and clean :-) When doing the conversion to unsigned, I also considered adding macros (or maybe nicer to use inline functions) for comparisons, to reduce the chance of messing up the needed type conversions, but ended up keeping things simple. Might still be good, though. Maybe a compromise could be to, at least for now, keep |
This was previously discussed as an aside in #10, but it deserves its own issue.
I previously wrote:
And:
Then @mkuyper wrote:
And:
The text was updated successfully, but these errors were encountered: