Skip to content

incorrect rounding in scaled_rounding with scale of 1 #1042

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

Open
dhebbeker opened this issue Mar 2, 2025 · 5 comments
Open

incorrect rounding in scaled_rounding with scale of 1 #1042

dhebbeker opened this issue Mar 2, 2025 · 5 comments
Labels

Comments

@dhebbeker
Copy link
Contributor

Most rounding functions in scaled_rounding don't work as intended if SCALING==1. I suggest to

  • either forbid to use a scaling of 1:
    • note in the documentation
    • static_assert in the code
  • or use template meta-programming to return value if SCALING==1

Can you please clarify which behaviour is intended? Then somebody could start a pull request...

Based on ETL version 20.40.0.

@dhebbeker dhebbeker changed the title incorrect rounding of in scaled_rounding with scale of 1 incorrect rounding in scaled_rounding with scale of 1 Mar 2, 2025
@jwellbelove
Copy link
Contributor

It's a long time since I last looked at these.

@jwellbelove
Copy link
Contributor

As I look at this again after 7 years, I can't help thinking that scale factors that are not a power of 10 do not really make a lot of sense.

@dhebbeker
Copy link
Contributor Author

The SCALING could be the size of a container or frame. The following example would make sense:

const unsigned numberOfNecessaryFrames = etl::round_infinity_unscaled<sizeof(Frame)>(payloadLength);

@jwellbelove
Copy link
Contributor

When I run that I get

for 8 bytes and frames of size 8: 2 frame(s) are necessary

Shouldn't that be 1 frame?

@dhebbeker
Copy link
Contributor Author

dhebbeker commented Mar 30, 2025 via email

@jwellbelove jwellbelove moved this from To do to In progress in Embedded Template Library Mar 30, 2025
@jwellbelove jwellbelove moved this from In progress to Done in Embedded Template Library Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants