Perhaps I am not familiar enough with how HiTech C handles sprintf, but i have an interesting problem.
I have two data types that are converted on a PIC16F1934. One is int, the other is a long.
In order to retain the fastest conversion possibly, I wanted to be able to call
sprintf(buffer,%d,integer)
when the integer type was used, then
sprintf(buffer,%ld,long)
when a long was needing to be converted. This was all done through an if statement.
However, I found that the execution time was way too slow with int inputs. Knowing this shouldn't be correct, I commented out the call to sprintf(buffer,%ld,long) and whoila, execution time was cut down dramatically. So I tested my if statement and found that it IS operating correctly, it seems when the compiler sees sprintf, it automatically loads the routine with the highest precision for the rest of the program.
Any ideas here?
I have two data types that are converted on a PIC16F1934. One is int, the other is a long.
In order to retain the fastest conversion possibly, I wanted to be able to call
sprintf(buffer,%d,integer)
when the integer type was used, then
sprintf(buffer,%ld,long)
when a long was needing to be converted. This was all done through an if statement.
However, I found that the execution time was way too slow with int inputs. Knowing this shouldn't be correct, I commented out the call to sprintf(buffer,%ld,long) and whoila, execution time was cut down dramatically. So I tested my if statement and found that it IS operating correctly, it seems when the compiler sees sprintf, it automatically loads the routine with the highest precision for the rest of the program.
Any ideas here?