Jump to content
UBot Underground

Trim extra decimals off a number


Recommended Posts

I have a script that generates a dollar value as a result after some hefty calculations.  IE $1299.99

 

My problem is the results are showing with like 10 decimals, for example I might get a result like 19.8888399221

 

Is there any way to strip any extra decimal after the second one to make it normal again?  For example the above would become 19.88 ... like a dollar value should be displayed :)

 

Thanks!

Link to post
Share on other sites

Use function find regular expression with regex like:

\d+(?=\.\d*)

You could also use function  replace regular expression with regex like:

\.\d*

and replace it with nothing. ;)

Link to post
Share on other sites

In one sentence, regular expression is used to extract data from strings.

 

In UBot you would use it like this:

set(#INTEGER, $find regular expression(1299.99, "\\d+(?=\\.\\d*)"), "Global")

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...