[chbot] HEX and ANSII ATMEGA and Delphi

Volker Kuhlmann list57 at top.geek.nz
Mon Oct 26 23:08:49 GMT 2020


On Mon 26 Oct 2020 19:12:20 NZDT +1300, Volker Kuhlmann wrote:

[...] Ugh, I got confused.

My previous email was about atoi(), which is a stdlib function, even
when I wrote itoa() or atoa(). I must have been very tired.
Always proofread to see if you any words out!

itoa() is not a standard function (partially I bet because of the usual
buffer size issues), but also because there's already the one and only
solution in the form of sprintf(), required for any formatted output to
e.g. the screen.

If in doubt, check K&C "The C Programming Language". Every C programmer
needs to have one...


For microcontrollers it is often lots more efficient to make your own,
especially if you know the integer widths and are dealing with hex only.
If you call printf() anywhere, use sprintf() (same guts, different
destination) because its code is already linked in. If you don't link it
in (it's big), it's fairly trivial to make your own shortint_to_hex() or
hex_to_shortint() with basic maths operators.

Ask again if you're still stuck.

I can't answer for Delphi, it was the rage(TM) when it wasn't available
for Linux, and when it became available for Linux, it was basically
obsolete.

Volker

-- 
Volker Kuhlmann
http://volker.top.geek.nz/	Please do not CC list postings to me.



More information about the Chchrobotics mailing list