sys/bcd: add bcd_buf_from_u32()#21308
Conversation
|
Isn't the dec_as_hex the same as binary coded decimals? I think there is already a helper for that. |
|
hah you are right! |
|
Sounds good to me. I'd personally search such a function in the bcd module, though. How about moving it there? |
|
I also thing that such a function in a string header is somewhat misleading. |
|
Ok, will move it to a new |
There already is https://doc.riot-os.org/group__sys__bcd.html |
|
Yes but that's just a header file 😉 |
|
I renamed the function and moved it to the |
Teufelchen1
left a comment
There was a problem hiding this comment.
I can't shake the feeling off that there's a off-by-one error in it. Oh well, can't find it nor proof it. So looks good to me! :D
Contribution description
This adds two helper functions to the
string_utilslibrary:reverse_buf()that inverts the order of bytes in an arraybcd_buf_from_u32()that takes a numberaand calculates a numbera'so that the hex string representation ofa'is the same as the decimal string representation ofa. e.g.bcd_buf_from_u32(123)would produce0x123.Testing procedure
This can be used to to generate pretty MAC / IP addresses from decimal serial numbers:
Issues/PRs references