09-24-2016 05:59 PM
For whatever reason I was having trouble using very small decimals (given in scientific notation) with the FilterByAttribute operator and thought rendering my value as a proper decimal might solve that and be easy enough to do. Turns out that (1) it was as easy as drawing a straight line (with my feet using only bezier curves) and (2) FilterByAttribute supports scientific notation so none of this was necessary, but I thought I'd share anyway since the picture widget is working.
So this sub-model takes a float in scientific notation and renders it as a string in decimal form.
The model essentially does a bunch of string processing. I remove the decimal and split the string at the exponent, write that piece out to a temp file (since it was impossible to cast text split from a string like "15" as any kind of number), read it back from the file as the Integer N, grab the first N zeros from a string of zeros, prefix that with a "0." and suffix it with the numerical part of the split string... ... ...
Wasn't a bad toy problem and I'm sure there's an easier approach.
Solved! Go to Solution.
09-26-2016 05:08 AM - edited 09-26-2016 05:12 AM
Hello Noel,
Nice model. Thank you for sharing your solution. Just it would not work if you will specify the number different from e-15.
I have some additional solution for you through simple Python script:
It displays up to 20 decimal places, tailing zeros are removed.
And then you can convert the number to string if you need. But I believe that idea is to get just decimal.
You can find model as well as *.py file in attachment.
P.S. It has it's own limitation as well. Numbers provided in scientific notation are converted to a floating-point binary representation and it is not possible to revert this process without losing information. The problem is floating point representation of real numbers on a computer uses base 2, not 10 and real numbers are approximated to the closest representation in binary system. There are additional limits connected with mantissa limits that holds significant digits of a floating point number.
But still it gives you some variation of possible inputs. And you always can modify the number of decimal places by changing the number (in red circle below):
Kind Regards,
Marina Vardovska
Post-Sales Engineer Remote Sensing
Hexagon Geospatial Division
09-26-2016 05:56 AM
09-26-2016 07:35 AM
Dear Noel,
My apologies. At some point to make it work with other number, I was need to re-run TableFileInput operator.
Sorry, my mistake. You have perfect solution for online usage.
Kind Regards,
Marina
09-26-2016 08:13 AM