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

Min/Max of 64-bit signals #56

Open
Felix-El opened this issue May 15, 2023 · 0 comments
Open

Min/Max of 64-bit signals #56

Felix-El opened this issue May 15, 2023 · 0 comments

Comments

@Felix-El
Copy link

When I create a unsigned 64-bit signal in the DBC (full range, no offset/scaling) the generated code fails to compile because the MAX constant has a value that exceeds u64 limits.

The issue seems to be:

  • min and max signal bounds are both stored as f64
  • f64 has only 52 mantissa bits so generally fails to store values above 2^52-1 with full accuracy
  • rounding occurs and the value stored in max (f64) is effectively larger than 2^64-1

This seems like a flaw in the design. Here are a few workarounds I can think of:

  1. If min / max are not interesting anyway and you can tweak the DBC, you can do that.
  2. dbc-codegen could add #[cfg(feature = "range_checked")] to the MIN and MAX constants so with range checking disabled at least there is no compilation error.

Has anyone else faced this issue before? Do you see a better way to work around the issue?
I'm willing to spend time on this but need some guidance.

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

No branches or pull requests

1 participant