Decimal
I'm in need of a script that will remove the decimal point of a number. For example: 13.22 -->> 1322 or 13.2 -->>13.20 or 13 -->> 1300 I'm unsure on how to do this.
Submitted by tekvaio (Programmer) on Jun 6, 2005
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
With that I think you would need to count the digits after the decimal to determine what to multiply by.
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
As long as your data never goes past the hundreths position.
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
If you know that the data will always be numbers potentially with a decimal then you could do
strNew = Replace(strOld, ".", "")
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
It is possible that I do not understand the end result, but I thought the desired result was to take any number that is provided and remove the decimal point from it. If that is the desired result, then this should work:
Replace(sourcetype, ".", "")
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
The Desired result is to have a implied decimal right justified... Must contain the same numbers(no rounding) 1222.33 -> 122233 or 1222.333 -> 1222333
Multiplying by 100 will only be correct for values with a hundreth of a decimal
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
Try this.
[tt]a=123456.7890123456
n=16 'fixed length
b=left(replace(a,".","")&string(n,"0"),n)
wscript.echo b
[/tt]
string is used for "big" number case.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.