Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use VBS to accurately calculate the 100th power of 2

Shulou Source: shulou.com Published: 2022-06-03 07:46:30 11月15日 Update

This article mainly introduces how to use VBS to accurately calculate the power of 2 to the 100th power, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Since Python can calculate the power of 2 to the 100th power, I will implement it in VBS. But this efficiency, it took 0.009013 seconds to calculate the 10000 power Python of 2, and 120.9805 seconds to VBS, which is not a level, so I won't say much.

Go directly to the code:

Date: 2010-10-27

'Author: Demon

'QQ: 380401911

'E-mail: still.demon@gmail.com

Begin = Timer

N = 1

For I = 1 To 100

N = multiple (n, 2)

Next

Finish = Timer

WScript.Echo n

WScript.Echo finish-begin

'Grade school multiplication, Algorithm 14.12

'http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf

Function multiple (byVal x, byVal y)

Dim n, t, I, j, z, w ()

N = Len (x)-1

T = Len (y)-1

ReDim w (n + t + 1)

X = CStr (x): y = CStr (y)

For I = 0 To UBound (w)

W (I) = "0"

Next

For I = 0 To t

Dim c: C = 0

Dim uv: uv = 0

For j = 0 To n

Uv = (w (iSj)-"0") + c + _

(Mid (xmeng / quotient 1)-"0") * (Mid (y _ recorder tmurified 1)-"0")

W (iConj) = CStr (uv Mod 10 + "0")

C = uv\ 10

Next

W (i+n+1) = CStr (uv\ 10 + "0")

Next

Z = Join (w, "")

Z = StrReverse (z)

Do While Left (zPower1) = "0"

Z = Mid (zpj2)

Loop

Multiple = z

End Function

Thank you for reading this article carefully. I hope the article "how to accurately calculate the 100th power of 2 with VBS" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Articles accuracy code value interest at the same time efficiency more friends knowledge grades editing industry information information channels channels references learning help support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MariaDB NVidia Huawei Microsoft