Jump to content

Accelerating double -> decimal string: solving problems you didn't know you had


Recommended Posts

I can see this solving a lot of annoyances we were having with the AQ Character Lineator.. Specifically the large amount of space constantly taken up by Doubles when just a few numbers would suffice. I look forward to hearing more about this integration and I have a feeling this can apply to a lot more situations than just ours.

Link to comment

Even in a CLFN the code is slower than the built-in primitive so I would not even bother a G implementation unless you are curious about the integer math.  In C++ code I use it all of the time, it rocks.  I do not care about the speed as much as a nice way to autoformat floating point numbers (it will do SGL as well). 

Link to comment

It's not a complete replacement, though, is it? I think this algo can fail with certain numbers so you'd have to fall-back to the printf and incur the overhead of running two in series. Maybe those numbers cropping up are statistically insignificant though.

Edited by ShaunR
Link to comment

There is a reason that the return value from the double to ascii function is a boolean.  I dropped it into a while loop and get a success rate of 99.6-99.7% for random samples over different ranges.

 

Running something which is roughly twice as fast 99.6% of the time and something which is 1.5 times slower (both in series) 0.4% of the time is still a net win.  That is of course in C++, in LV the CLFN implementation of the fast method is roughly 1.5x slower than the primitive implementation of the slow method.

 

I have not used this for speed, I use it to get the smallest representation.  I have written custom graph and table views in C++ and needed to do the float to string conversion.

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.