- Community
- :
- Discussions
- :
- ERDAS IMAGINE
- :
- Re: HOWTO: Convert a number in scientific notation...

MENU
## ERDAS IMAGINE

Discuss and share topics of interest using ERDAS IMAGINE the world’s leading geospatial data authoring system.

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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.

Message 1 of 5
(2,413 Views)

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

[ Edited ]
Options

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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

Kind Regards,

Marina Vardovska

Hexagon Geospatial Support

Marina Vardovska

Hexagon Geospatial Support

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-26-2016 05:56 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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

Kind Regards,

Marina Vardovska

Hexagon Geospatial Support

Marina Vardovska

Hexagon Geospatial Support

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-26-2016 08:13 AM

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

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.