VBScript Tutorials - Herong's Tutorial Examples - v6.02, by Herong Yang
"^" - Arithmetic Exponentiation Operation
This section provides some detail rules and a tutorial example on how arithmetic exponentiation operation works in VBScript.
Here are some detail rules about the arithmetic operation - exponentiation:
Here is a tutorial example showing you how arithmetic modulus operation rules work:
<html> <body> <!-- exponentiation_operation.html - Copyright (c) 1998 HerongYang.com. All Rights Reserved. --> <pre> <script language="vbscript"> document.writeln("2^3=" & (2^3) & " : " & TypeName(2^3)) document.writeln("2^31=" & (2^31) & " : " & TypeName(2^31)) document.writeln("2^64.5=" & (2^64.5) & " : " & TypeName(2^64.5)) document.writeln("2^0.5=" & (2^0.5) & " : " & TypeName(2^0.5)) document.writeln("2^0=" & (2^0) & " : " & TypeName(2^0)) document.writeln("0^0=" & (0^0) & " : " & TypeName(0^0)) document.writeln("0^1=" & (0^1) & " : " & TypeName(0^1)) document.writeln("2^-1=" & (2^-1) & " : " & TypeName(2^-1)) document.writeln("2^-3=" & (2^-3) & " : " & TypeName(2^-3)) document.writeln("-2^-3=" & (-2^-3) & " : " & TypeName(-2^-3)) ' document.writeln("-2^0.5=" & (-2^0.5) & " : " & TypeName(-2^0.5)) document.writeln("3.33^9.99=" & (3.33^9.99) & " : " _ & TypeName(3.33^9.99)) document.writeln("3^""7""=" & (3^"7") & " : " & TypeName(3^"7")) ' document.writeln("3^""7Hello""=" & (3^"7Hello") & " : " _ ' & TypeName(3^"7Hello")) document.writeln("3^True=" & (3^True) & " : " & TypeName(3^True)) document.writeln("3^False=" & (3^False) & " : " _ & TypeName(3^False)) ' document.writeln("False^True=" & (False^True) & " : " _ ' & TypeName(False^True)) document.writeln("Empty^3=" & (Empty^3) & " : " _ & TypeName(Empty^3)) </script> </pre> </body> </html>
Here is the output of this VBScript example script:
2^3=8 : Double 2^31=2147483648 : Double 2^64.5=2.60876356506656E+19 : Double 2^0.5=1.4142135623731 : Double 2^0=1 : Double 0^0=1 : Double 0^1=0 : Double 2^-1=0.5 : Double 2^-3=0.125 : Double -2^-3=-0.125 : Double 3.33^9.99=165660.089908899 : Double 3^"7"=2187 : Double 3^True=0.333333333333333 : Double 3^False=1 : Double Empty^3=0 : Double
The output confirms some of arithmetic exponentiation operation rules:
Table of Contents
Introduction of VBScript - Visual Basic Scripting Edition
Variant Data Type, Subtypes, and Literals
Introduction of Arithmetic Operations
"+" - Arithmetic Addition Operation
"-" - Arithmetic Subtraction Operation
"*" - Arithmetic Multiplication Operation
"/" - Arithmetic Division Operation
"\" - Arithmetic Integer Division Operation
"Mod" - Arithmetic Modulus Operation
►"^" - Arithmetic Exponentiation Operation
Numeric Comparison Operations and Logical Operations
String Operations - Concatenation and Comparison
Variable Declaration and Assignment Statement
Expression and Order of Operation Precedence
Statement Syntax and Statement Types
Array Data Type and Related Statements
Array References and Array Assignment Statements
Conditional Statements - "If ... Then" and "Select Case"
Loop Statements - "For", "While", and "Do"
"Function" and "Sub" Procedures
Inspecting Variables Received in Procedures
Error Handling Flag and the "Err" Object
Regular Expression Pattern Match and Replacement
scrrun.dll - Scripting Runtime DLL Library
IE Web Browser Supporting VBScript