RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

sys/turo: Add decimal integer printer

Open MrKevinWeiss opened this issue 4 years ago • 8 comments

Contribution description

As a way around using floats and to prevent code bloat a turo_s32_frac is added to the turo API. The functionality is based on the fmt_s32_dfp from the fmt.h library, however, since a fixed length print buffer is needed we add some constraints to the overall functionality. This will only be allowed to insert a decimal within an existing int32, not be able to multiply by 10s or be able to divide more that TENMAP (8) 10s.

Testing procedure

Murdock green (unittests and tests/turo)

Issues/PRs references

Can be used by #17029 Depends on #17072

MrKevinWeiss avatar Oct 27 '21 10:10 MrKevinWeiss

Though the tests/turo addition does a good job at confirming the json parsability I would like to add it to unittests (just to make sure no more spurious asserts) but I would like #17037 in first...

MrKevinWeiss avatar Oct 28 '21 07:10 MrKevinWeiss

This needs a rebase @MrKevinWeiss!

fjmolinas avatar Dec 08 '21 10:12 fjmolinas

Needs a bit more of a rebase, it needs some rework and also implementation of the fmt print_s32_frac_dec

MrKevinWeiss avatar Dec 08 '21 10:12 MrKevinWeiss

@MrKevinWeiss, any estimate whether you will have the time to work on it for the upcoming release?

OlegHahm avatar Mar 09 '22 12:03 OlegHahm

yup, maybe end of the week.

MrKevinWeiss avatar Mar 09 '22 12:03 MrKevinWeiss

Though I don't know if @kaspar030 still wants it...

MrKevinWeiss avatar Mar 09 '22 12:03 MrKevinWeiss

Well a bit of a rework. Since there can be a pretty large amount of digits to print I needed some flushable way of dumping leading and trailing 0s. The brought be down something of a rabbit hole.

I will need to clean this up (ran out of time today) but I don't know if this is desirable or if we just want to use some sort of 1.234e-10 type of notation instead (at least we can know our bounds.

Since this is based on the s32_dfp function from @kaspar030 (I think it still is nice to have some scaling function that doesn't use floats), maybe he can give some feedback on the approach (not the code as this will be cleaned later).

MrKevinWeiss avatar Mar 11 '22 10:03 MrKevinWeiss

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

stale[bot] avatar Sep 21 '22 05:09 stale[bot]

I don't think this is needed anymore

MrKevinWeiss avatar Sep 27 '22 11:09 MrKevinWeiss