How to simplify long number to exponent form?

I’m currently working on a calculator app and I’m facing a problem whereby the result of an operation can sometimes be too long to fit properly in the Label, especially since I set the label to have only one line for aesthetic purposes. My question is , how do I convert the number to exponent form, for example, 3.22e+5 or 6.55e-7 when the length of the number exceed a certain threshold ? Thanks

Sounds like a job for an IF statement @nzgswbzhcxbdysblek12 - but you’ll need to write your own function to convert from integer to exponent form.

Do you have any screenshots for what you’ve tried so far?

1 Like

@domhnallohanlon Actually I need to convert float number with infinite number of decimal places to the exponent form. I tried to manipulate the numbers with String operation but to no avail. For example, I first identify the index of the decimal point (the dot) using the find occurrence function. Then I would extract the substring starting from the decimal point up until the last number . Then I would find the length of that substring using the length function. If the length of the substring exceeds for example 7, I would convert it to exponent form. Problem is, it seems that String operation doesn’t work on this kind of numbers and undefined is returned when I tried to extract the substring.

Here’s a demo I made.

https://x.thunkable.com/copy/085c225da346cbe8a16e997c85706b64

Screen Shot 2020-05-02 at 4.02.38 PM

1 Like

Nice workkkkk! @tatiang