Sign in to follow this  
Followers 0
CheeseBiscuit

Trying to convert a tiny number (0.000000002) so I can do calulations on it..

5 posts in this topic

For example, I have a number "0.00000002", now to do calculations on it would make it 4e-008, I don't want that, I want it to stay in the same format as "0.00000002" + whatever I did to it so like "0.00000038"

So I tried manipulating it as a string and so far I got this:

#include <String.au3>

Local $Num = InputBox("InputNum", "Enter Number", "0.00000002", "")

Local $NumSplitP1 = StringTrimLeft($Num, 2) ;Removes 0.
Local $NumSplitP2 = StringReplace($NumSplitP1, "0", "") ;Removes all instances of 0
MsgBox(64, "Num", $NumSplitP2)

But as you can painfully see, I am limited with numbers like 1000 or any number that has a 0 in it..

Basically I'm trying to do maths on a really tiny number but want its format to stay the same, with all the decimal and 0's. I know it has to be possible right? :(

Share this post


Link to post
Share on other sites



And here is another alternative.

Local $Num = InputBox("InputNum", "Enter Number", "0.00000002", "")

MsgBox(0, "Results", $Num & " x 2 = " & $Num * 2 & " or  " & StringRegExpReplace(StringFormat("%.15f", $Num * 2), "0+$|\.0+$", ""))

; Returns:-  0.00000002 x 2 = 4e-008 or  0.00000004

Share this post


Link to post
Share on other sites

Smart  :lmao: 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0