Convert scientific notation to decimal?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Convert scientific notation to decimal?

Post by ClipArtGuy » Fri Sep 29, 2017 4:37 am

I'm looking for a way to convert a number represented in scientific notation such as "9.0260588394524e-5 " to a more human readable decimal format. Is there a function for this in LC?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10327
Joined: Wed May 06, 2009 2:28 pm

Re: Convert scientific notation to decimal?

Post by dunbarx » Fri Sep 29, 2017 5:01 am

It would be fun to write such a function, simple and straightforward, but do check out the "format" function in the dictionary. That gadget is an embarrassment of riches for just the sort of thing you asked for.

Craig Newman

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Convert scientific notation to decimal?

Post by Thierry » Fri Sep 29, 2017 8:03 am

ClipArtGuy wrote:I'm looking for a way to convert a number represented in scientific notation such as "9.0260588394524e-5 " to a more human readable decimal format. Is there a function for this in LC?
Hi ClipArtGuy,

check format() in the dictionary.

Code: Select all


   put "9.0260588394524e-5" into X
   put format( "%s to floating point: %.6f ", X, X )

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: Convert scientific notation to decimal?

Post by ClipArtGuy » Fri Sep 29, 2017 5:28 pm

Thanks Craig and Thierry! It looks like format() is exactly what I needed.

Post Reply