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

consider using I32 instead of U32 for Time #3034

Open
mwette opened this issue Nov 20, 2024 · 0 comments
Open

consider using I32 instead of U32 for Time #3034

mwette opened this issue Nov 20, 2024 · 0 comments

Comments

@mwette
Copy link

mwette commented Nov 20, 2024

F´ Version 3.5.0
Affected Component Fw/Time

Feature Description

Time uses U32 to encode seconds and microseconds. Consider using I32 for these. There will arise the need to subtract times.

Rationale

  1. Consider the case of subtracting 2^32 from 0 seconds. You need 33 bits for that.
  2. A subtraction needs to return a time-difference type. If you use I32, Time can be used.
  3. I32 is still big enough to add or subtract two values of nanoseconds, if you ever change to that.
  4. Changing U32 to I32 is unlikely to break any existing code (that does not subtract time).

If you look in POSIX implementations for struct timespec you'll see that usually long and not unsigned long is used. I guess it is for the reasons above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant