Float to ASCII conversion without using sprintf function

Hello,

I am removing all sprintf() function from my souce code as this function does not allow me to set the proper thread stack size. Does anyone have any function that implements this conversion?

Thanks
Andre Moutinho

Parents
  • Too answer your first question, I don't believe it's obvious too you but making such a function is NO TRIVIAL matter. In fact it is quite a bit of work, you must account for +-INF 0 +-NAN just to name a few for floating point. In addition to these you must take care to get correct rounding and the sign of the number as well.

    Don't belittle the lowly printf formatting functions because Keil put an inordinate amount of effort to get those to work let alone work correctly (they are very good).

    I say this because I've had to do just what you were asking a while ago, it's not exactly a simple exercise AND you MUST know the format of the floating point data you are working with, there is lot of research needed before even starting. If you plan on doing this, good luck, it's about 8 days of work and testing. Also there are a considerable number of academic papers on the subject matter. It's not trivial, and that's just floating point (not the other myriad of functions that the vaprintf family performs).

    You may wish to look at the SDCC library if you want a reference. I had to write all of my code in C, and it cannot be made freely available (I don't own it).

    I can say it's doable, but you must select carefully what you wish to use out of the vaprintf family of formatting commands first.

    Stephen

Reply
  • Too answer your first question, I don't believe it's obvious too you but making such a function is NO TRIVIAL matter. In fact it is quite a bit of work, you must account for +-INF 0 +-NAN just to name a few for floating point. In addition to these you must take care to get correct rounding and the sign of the number as well.

    Don't belittle the lowly printf formatting functions because Keil put an inordinate amount of effort to get those to work let alone work correctly (they are very good).

    I say this because I've had to do just what you were asking a while ago, it's not exactly a simple exercise AND you MUST know the format of the floating point data you are working with, there is lot of research needed before even starting. If you plan on doing this, good luck, it's about 8 days of work and testing. Also there are a considerable number of academic papers on the subject matter. It's not trivial, and that's just floating point (not the other myriad of functions that the vaprintf family performs).

    You may wish to look at the SDCC library if you want a reference. I had to write all of my code in C, and it cannot be made freely available (I don't own it).

    I can say it's doable, but you must select carefully what you wish to use out of the vaprintf family of formatting commands first.

    Stephen

Children
More questions in this forum