Hi All
I'm trying to write my own "ftoa" function, as a part of my performance CString class (CFString). Since I aim performance I can't use sprintf() or any other standard method to do the job. Actually I'm supposed to match the performance of my function against sprintf() and others standard solutions like CString::Format().
I'm actually almost done, but the last push seems to be the hardest! :)
The IEEE-754 standard imposes a few cases which require different approach in order to extract the value into string, according to the binary exponent's value. They are:
if(exp > 31)
{
}
else if(exp < -31)
{
}
else if(exp < 31 && exp >= 23)
{
}
else if(exp < 23 && exp >= 0)
{
}
else if(exp < 0 && exp >= -23)
{
}
This is the overall structure of my ftoa (although it's body is entirely implemened in assembly).
Now my question is how to solve the case with exp > 31? :)
I've done a lot of research on IEEE-754 standard but some details never got quite clear to me.
I've found just two useful examples which helped me but their goal is to merely do the job, no performance issues taken into account, and very limited functionality. For example, the one doesn't process the cases (exp > 31) and (exp < -31) at all, the other is even worse! :laugh:
I even tried to debug sprintf() itself looking into its disassembly but the code is way too messy for me. :)
And of course if you google "How to convert float to string" almost all the answers will be -> use sprintf()
So considering the amount of time I've spent any help will be greatly appreciated! :)