Sha256: e9a0b351fbe27bc0f72b56b56c375bf83938b9d497995e78e95111d05b43be58
Contents?: true
Size: 1.02 KB
Versions: 10
Compression:
Stored size: 1.02 KB
Contents
VBScript's variables are all Variants. What starts out as an integer may be converted to something else if the need arises. ===Implementation=== option explicit dim a, b wscript.stdout.write "A? " a = wscript.stdin.readline wscript.stdout.write "B? " b = wscript.stdin.readline a = int( a ) b = int( b ) wscript.echo "a + b=", a + b wscript.echo "a - b=", a - b wscript.echo "a * b=", a * b wscript.echo "a / b=", a / b wscript.echo "a \ b=", a \ b wscript.echo "a mod b=", a mod b wscript.echo "a ^ b=", a ^ b ===Another Implementation=== Gives the same output for the same input. Inspired by Python version. option explicit dim a, b wscript.stdout.write "A? " a = wscript.stdin.readline wscript.stdout.write "B? " b = wscript.stdin.readline a = int( a ) b = int( b ) dim op for each op in split("+ - * / \ mod ^", " ") wscript.echo "a",op,"b=",eval( "a " & op & " b") next ===Invocation=== C:\foo>arithmetic.vbs A? 45 B? 11 a + b= 4511 a - b= 34 a * b= 495 a / b= 4.09090909090909 a \ b= 4 a mod b= 1 a ^ b= 1.5322783012207E+18
Version data entries
10 entries across 7 versions & 1 rubygems