## ERDAS IMAGINE

Discuss and share topics of interest using ERDAS IMAGINE the world’s leading geospatial data authoring system.
Showing results for
Do you mean
Highlighted
Frequent Contributor
Posts: 106
Registered: ‎06-03-2016

# HOWTO: Convert a number in scientific notation to a decimal

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.

Staff
Posts: 127
Registered: ‎07-04-2016

## Re: HOWTO: Convert a number in scientific notation to a decimal

[ Edited ]

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

Kind Regards,
Marina Vardovska
Hexagon Geospatial Support
Frequent Contributor
Posts: 106
Registered: ‎06-03-2016

## Re: HOWTO: Convert a number in scientific notation to a decimal

Good grief. All that effort and it doesn't work! That's just too funny!

Thanks for shining a light on the Python operator.

I tend to steer clear of the operators I can't use online, but appreciate your effort, the lengthy explanation, and the humor.

Cheers

Staff
Posts: 127
Registered: ‎07-04-2016

## Re: HOWTO: Convert a number in scientific notation to a decimal

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

Kind Regards,
Marina Vardovska
Hexagon Geospatial Support
Frequent Contributor
Posts: 106
Registered: ‎06-03-2016

## Re: HOWTO: Convert a number in scientific notation to a decimal

Oh, no need to apologize. I started my day with a good laugh; thank you very much.

I knew there had to be a better way - there often is - and there it is.

Regards
Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.