IB enhancements for Comet32
From CometWiki
(Difference between revisions)
m (reformat) |
|||
| Line 8: | Line 8: | ||
Comet32 Numeric Processing | Comet32 Numeric Processing | ||
| - | + | * Comet32 provides much enhanced numeric handling over Comet16. These Specs may change prior to official release. | |
| - | + | * Numeric variables can be as long as 32 decimal places. This is twice the length of Comet16. | |
| - | + | * Expression results are calculated to length 64.32 so that partial results of expressions are preserved. | |
| - | + | * The following Comet16 Functionality is supported:: | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
Add, z = x + y | Add, z = x + y | ||
| - | |||
Subtract, z = x - y | Subtract, z = x - y | ||
| - | |||
Multiply, z = x * y | Multiply, z = x * y | ||
| - | |||
Divide, z = x / y | Divide, z = x / y | ||
| - | |||
Negate, z = - x | Negate, z = - x | ||
| - | |||
Abs, z = abs(x) -- Return the absolute value of x | Abs, z = abs(x) -- Return the absolute value of x | ||
| - | |||
Int, z = int(x) -- Return the integer portion of x | Int, z = int(x) -- Return the integer portion of x | ||
| - | |||
Fpt, z = abs(x) -- Return the fractional portion of x | Fpt, z = abs(x) -- Return the fractional portion of x | ||
| - | |||
Sgn, z = abs(x) -- Return the sign of x (-1,0,+1) | Sgn, z = abs(x) -- Return the sign of x (-1,0,+1) | ||
| - | |||
Num, z = num(a$,err) -- Return the string a$ converted to a number. | Num, z = num(a$,err) -- Return the string a$ converted to a number. | ||
| - | |||
Asc, z = asc(a$) -- Return the ascii equivalent of the first character in a$. | Asc, z = asc(a$) -- Return the ascii equivalent of the first character in a$. | ||
| - | |||
Len, z = len(a$) -- Return the length of string a$. | Len, z = len(a$) -- Return the length of string a$. | ||
| - | |||
BitwiseAnd, z = x and y | BitwiseAnd, z = x and y | ||
| - | |||
BitwiseOr, z = x or y | BitwiseOr, z = x or y | ||
| - | |||
BitwiseXor, z = x xor y | BitwiseXor, z = x xor y | ||
| - | |||
BitwiseNot, z = not(x) | BitwiseNot, z = not(x) | ||
| - | |||
Mod, z = x mod y -- Divides int(x) by int(y) and return the remainder | Mod, z = x mod y -- Divides int(x) by int(y) and return the remainder | ||
| - | |||
Sqrt, z = sqrt(x) -- Return the Square Root of x | Sqrt, z = sqrt(x) -- Return the Square Root of x | ||
| - | |||
Rnd, z = rnd() -- Return a "random number" between 0 and 1 | Rnd, z = rnd() -- Return a "random number" between 0 and 1 | ||
| - | + | Many additional math functions are supported in Comet32: | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
Cbrt, z = cbrt(x) -- Return the Cube Root of x | Cbrt, z = cbrt(x) -- Return the Cube Root of x | ||
| - | |||
Log, z = log(x) -- Return the base-e logarithm of x, so x==exp(z) | Log, z = log(x) -- Return the base-e logarithm of x, so x==exp(z) | ||
| - | |||
Log10, z = log10(x) -- Return the base-10 logarithm of x, so x==pow(10,z) | Log10, z = log10(x) -- Return the base-10 logarithm of x, so x==pow(10,z) | ||
| - | |||
Exp, z = exp(x) -- Return e raised to the power x, so x==log(z) | Exp, z = exp(x) -- Return e raised to the power x, so x==log(z) | ||
| - | |||
Pow, z = pow(x,y) -- Return x raised to the power y | Pow, z = pow(x,y) -- Return x raised to the power y | ||
| - | |||
Sin, z = sin(x) -- Return the sine of x, with x in radians | Sin, z = sin(x) -- Return the sine of x, with x in radians | ||
| - | |||
Cos, z = cos(x) -- Return the cosine of x, with x in radians | Cos, z = cos(x) -- Return the cosine of x, with x in radians | ||
| - | |||
Tan, z = tan(x) -- Return the tangent of x, with x in radians | Tan, z = tan(x) -- Return the tangent of x, with x in radians | ||
| - | |||
Asin, z = asin(x) -- Return the inverse sine of x, in radians | Asin, z = asin(x) -- Return the inverse sine of x, in radians | ||
| - | |||
Acos, z = acos(x) -- Return the inverse cosine of x, in radians | Acos, z = acos(x) -- Return the inverse cosine of x, in radians | ||
| - | |||
Atan, z = atan(x) -- Return the inverse tangent of x, in radians | Atan, z = atan(x) -- Return the inverse tangent of x, in radians | ||
| - | |||
Atan2, z = atan2(y,x) -- Return the 4 quadrant inverse tangent of y/x | Atan2, z = atan2(y,x) -- Return the 4 quadrant inverse tangent of y/x | ||
| - | |||
Sinh, z = sinh(x) -- Return the hyperbolic sine of x | Sinh, z = sinh(x) -- Return the hyperbolic sine of x | ||
| - | |||
Cosh, z = cosh(x) -- Return the hyperbolic cosine of x | Cosh, z = cosh(x) -- Return the hyperbolic cosine of x | ||
| - | |||
Tanh, z = tanh(x) -- Return the hyperbolic tangent of x | Tanh, z = tanh(x) -- Return the hyperbolic tangent of x | ||
| - | |||
Asinh, z = asinh(x) -- Return the inverse hyperbolic sine of x | Asinh, z = asinh(x) -- Return the inverse hyperbolic sine of x | ||
| - | |||
Acosh, z = acosh(x) -- Return the inverse hyperbolic cosine of x | Acosh, z = acosh(x) -- Return the inverse hyperbolic cosine of x | ||
| - | |||
Atanh, z = atanh(x) -- Return the inverse hyperbolic tangent of x | Atanh, z = atanh(x) -- Return the inverse hyperbolic tangent of x | ||
| - | |||
Factorial, z = factorial(x)-- Return the factorial of x | Factorial, z = factorial(x)-- Return the factorial of x | ||
| - | |||
Floor, z = floor(x) -- Return the floor (next lowest integer value) of x. | Floor, z = floor(x) -- Return the floor (next lowest integer value) of x. | ||
| - | |||
Ceil, z = ceil(x) -- Return the ceil (next highest integer value) of x. | Ceil, z = ceil(x) -- Return the ceil (next highest integer value) of x. | ||
| - | |||
Gcd, z = gcd(x,y) -- Return the GCD (greatest common divisor) of x, y. | Gcd, z = gcd(x,y) -- Return the GCD (greatest common divisor) of x, y. | ||
| - | |||
Lcm, z = lcm(x,y) -- Return the LCM (least common multiple) of x, y. | Lcm, z = lcm(x,y) -- Return the LCM (least common multiple) of x, y. | ||
| - | + | Beware! The following code will not work the same for Comet32 as it did for Comet16: | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
For I = 0 to 99 | For I = 0 to 99 | ||
| - | |||
A$ = "T" + sub(str(i+100),15,2) | A$ = "T" + sub(str(i+100),15,2) | ||
| - | |||
Next i | Next i | ||
| - | + | Because the result of the addition is in the accumulator which has changed. | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| + | The following code will ALWAYS work for both Comet16 and Comet32: | ||
For I = 0 to 99 | For I = 0 to 99 | ||
| - | |||
A$ = `T' + sub(strip(str(i+100)),2,2) | A$ = `T' + sub(strip(str(i+100)),2,2) | ||
| - | |||
Next I | Next I | ||
Revision as of 18:40, 2 September 2010
Comet32 Numeric Processing
- Comet32 provides much enhanced numeric handling over Comet16. These Specs may change prior to official release.
- Numeric variables can be as long as 32 decimal places. This is twice the length of Comet16.
- Expression results are calculated to length 64.32 so that partial results of expressions are preserved.
- The following Comet16 Functionality is supported::
Add, z = x + y
Subtract, z = x - y
Multiply, z = x * y
Divide, z = x / y
Negate, z = - x
Abs, z = abs(x) -- Return the absolute value of x
Int, z = int(x) -- Return the integer portion of x
Fpt, z = abs(x) -- Return the fractional portion of x
Sgn, z = abs(x) -- Return the sign of x (-1,0,+1)
Num, z = num(a$,err) -- Return the string a$ converted to a number.
Asc, z = asc(a$) -- Return the ascii equivalent of the first character in a$.
Len, z = len(a$) -- Return the length of string a$.
BitwiseAnd, z = x and y
BitwiseOr, z = x or y
BitwiseXor, z = x xor y
BitwiseNot, z = not(x)
Mod, z = x mod y -- Divides int(x) by int(y) and return the remainder
Sqrt, z = sqrt(x) -- Return the Square Root of x
Rnd, z = rnd() -- Return a "random number" between 0 and 1
Many additional math functions are supported in Comet32:
Cbrt, z = cbrt(x) -- Return the Cube Root of x
Log, z = log(x) -- Return the base-e logarithm of x, so x==exp(z)
Log10, z = log10(x) -- Return the base-10 logarithm of x, so x==pow(10,z)
Exp, z = exp(x) -- Return e raised to the power x, so x==log(z)
Pow, z = pow(x,y) -- Return x raised to the power y
Sin, z = sin(x) -- Return the sine of x, with x in radians
Cos, z = cos(x) -- Return the cosine of x, with x in radians
Tan, z = tan(x) -- Return the tangent of x, with x in radians
Asin, z = asin(x) -- Return the inverse sine of x, in radians
Acos, z = acos(x) -- Return the inverse cosine of x, in radians
Atan, z = atan(x) -- Return the inverse tangent of x, in radians
Atan2, z = atan2(y,x) -- Return the 4 quadrant inverse tangent of y/x
Sinh, z = sinh(x) -- Return the hyperbolic sine of x
Cosh, z = cosh(x) -- Return the hyperbolic cosine of x
Tanh, z = tanh(x) -- Return the hyperbolic tangent of x
Asinh, z = asinh(x) -- Return the inverse hyperbolic sine of x
Acosh, z = acosh(x) -- Return the inverse hyperbolic cosine of x
Atanh, z = atanh(x) -- Return the inverse hyperbolic tangent of x
Factorial, z = factorial(x)-- Return the factorial of x
Floor, z = floor(x) -- Return the floor (next lowest integer value) of x.
Ceil, z = ceil(x) -- Return the ceil (next highest integer value) of x.
Gcd, z = gcd(x,y) -- Return the GCD (greatest common divisor) of x, y.
Lcm, z = lcm(x,y) -- Return the LCM (least common multiple) of x, y.
Beware! The following code will not work the same for Comet32 as it did for Comet16:
For I = 0 to 99
A$ = "T" + sub(str(i+100),15,2)
Next i
Because the result of the addition is in the accumulator which has changed.
The following code will ALWAYS work for both Comet16 and Comet32:
For I = 0 to 99
A$ = `T' + sub(strip(str(i+100)),2,2)
Next I