I have been scratching my head why wm_itoa is not returning the actual value. This is just a simple conversion.
num = 67;
I believe the expected value of aa is 43 (hex), but it is still 67.
Am I missing something?
I believe that wm_itoa() is a macro wrapped around itoa(). As itoa() takes a third argument (the radix) I suspect that the wm_itoa() macro has the radix set to 10.
You can have a look through the header files yourself and see how the macro is constructed. I’ll have a look myself when I get back into the office.
If you want to be sure about the conversion (and you only want octal, hex, or decimal conversions) you are probably better off using wm_sprintf() to build the ascii representation of your number.
I’ve just had a look at the header file (wm_stdio.h, for OS 6.52) and I’ve found that a number of the wm_XXX functions are macros over the standard library equivalents, wm_itoa() is NOT, and is defined as follows:
ascii * wm_itoa ( s32 a, ascii *szBuffer );
This could be because itoa() is not a standard function defined by ANSII C and is left to the compiler developers to implement if and when required.
It looks like SiWi have chosen to implement it to only convert with a radix 10. I will note that this is NOT mentioned in the ADL user guide - section 126.96.36.199 (OS 6.52, Standard C Function Set) indicates that wm_itoa() is available, but NOT that it defaults to radix 10.
Looks like you’re going to be better off using wm_sprintf() - or implementing your own version of itoa().
That was also my hunch that wm_itoa is not using a radix of 16, and yes wm_itoa() is not a macro wrapped around itoa because there is no itoa when I clicked on its reference.
I did use wm_sprintf() before I read your reply.
Anyway, thanks for the detailed explanation.