c:\Test>vpc VPC(Variable Precision Calculator V2) of Bigdecimal(V11) Copyright (c) 2024 by Shigeo Kobayashi. Allrights reserved. Enter command >a = pi();?a a = 0.3141592653 5897932384 6264338327 9502884197 1693993751 0582097494 4592307816 4062862089 9862803482 5342117068 E1 >$precision = 200 >b = pi() >?b b = 0.3141592653 5897932384 6264338327 9502884197 1693993751 0582097494 4592307816 4062862089 9862803482 5342117067 9821480865 1328230664 7093844609 5505822317 2535940812 8481117450 2841027019 3852110555 9644622948 9549303819 6E1 >
Enter command >a=pi()/4;b= power(sin(a),2) + power(cos(a),2);?a;?b a = 0.7853981633 9744830961 5660845819 8757210492 9234984377 6455243736 1480769541 0157155224 9657008706 3355292669 9554E0 b = 0.1E1
?* ... Value of all valrables and settings are printed.
?$ ... Value of all settings are printed.
a = pi()But writing 'a = pi() ?a' without using ';' will be an error.
?a
a='pi'() is correct, but a=' pi '() is an error('pi' is a function name,but ' pi ' is not).
a=1000 is correct. a= " - 10.0 1" is regarded as a=-10.01 and is also correct. Spaces(and characters specified by $format) in a numerical expression are ignored.- Iterations:
repeat or while (repeated to the end of line)can be used.- Input/Output:
write ".\result.txt" saves all variable values and settings to the file ".\result.txt" which can be restored by read ".\result.txt".- Comment:
# means the start of comment and any character from # to the end of line will be ignored,
Function name | Description | Example | Remarks |
---|---|---|---|
atan(a) | computes arctangent of a c = tan-1(a) |
>a=0.5;c=atan(a);?a a = 0.8414709848 0789650665 ... 5435E0 | |a|<=1 |
sin(a)/cos(a) | computes trigonometric function |
>a=sin(1);?a;b=cos(1);?b;c=a*a+b*b;?c a = 0.8414709848 0789650665 ... 5435E0 b = 0.5403023058 6813971740 ... 4357E0 c = 0.1E1 |
the argument value must be radian, not degree, and must be small enough. If the argument(a) is greater than 3.14...,then you must adjust a as a=a-3.14.. before calling sin(a) or cos(a). |
exp(a) | computes exponentiation of Napier's number(base of natural logarithm:ea). |
>a=exp(1);?a a = 0.2718281828 4590452353 ... 4E1 | |
ln(a) | computes natural logarithm(base of Napier's number). Logea |
>a=ln(0.5);?a;b=exp(a);?b a = -0.6931471805 5994530941 723... 42E0 b = 0.5E0 | 0 < a <= 2 |
pi() | computes ratio of a circle's circumference(π). |
>a=pi();?a a = 0.3141592653 5897932384 ...068 E1 | brackets () are necessary. |
sqrt(a) | computes square root a=b1/2 |
>a=sqrt(5);?a a = 0.2236067977 4997896964 ...275 E1 | a >= 0 |
iterations() | returns total number of iteration count just before. |
>a=sqrt(2);b=iterations();?a;?b a = 0.1414213562 3730950488 0168872420 ...7E1 b = 0.2E2 | iterations() <= $max_iterations |
Function name | Description | Example | Remarks |
---|---|---|---|
abs(a) | computes absolute value of a. |
>a=-1;b=abs(a);?b b = 0.1E1 | |
power(a,n) | computes n power of a b=power(a,n) => b=an |
>b=power(2,-2);?b b = 0.25E0 | n must be a positiove or negative integer. b = power(2,0.5) is an error. |
int(a) | extracts integer part of a. |
>a=(1/3)*100;b=int(a);?b b = 0.33E2 | |
frac(a) | extracts fraction part of a. |
>a=(1/3)*100;b=frac(a);?b b = 0.3333333333 3333333333 ... 33 E0 | |
digits(a) | returns number of effective digits of a. |
>a=(1/3)*2;?a;b=digits(a);?b a = 0.6666666666 6666666666 ... 666 6667E0 b = 0.104E3 | |
exponent(a) | returns an integer number of exponent of a. a=0.xxxx*10n exponent(a) returns n. |
>a=power(10,3);?a;b=exponent(a);?b a = 0.1E4 b = 0.4E1 |
Function name | Description | Example |
---|---|---|
trim(a,n) | trim(a,n) means,rounding operation is done on the (n+1)th digit counted from the left most position of a according to the specification of $round. After rounding, a consists of n digits at most. | >$format=F;a=1234.5678;b=trim(a,4);c=round(a,1);d=round(a,-1);e=round(a,0);?a;?b;?c;?d;?e # results are as follows |
round(a,i) |
round(a,i) rounds a at the i-th position where i is the relative position counted from the decimal point.
If i>=0,then the degit at (i+1)th position from the decimal point to the right is rounded. The total count of digits after the decimal point will be i at most. If i<0 then,the i-th digit from the decimal point to the left is rounded. As the result,at least i zeros appear from the decimal point to the left. |
a = 1234.5678 b = 1235 c = 1234.6 d = 1230 e = 1235 |
Round method | Meaning | Example |
---|---|---|
up | round away from zero. |
>$round=up;a=-1/3;b=round(a,0);?b b = -0.1E1 |
down | round towards zero(truncate). |
>$round=down;a=-1/3;b=round(a,0);?b b = -0.0 |
half_up | round up if the digit >= 5 otherwise truncated(default). |
>a=-2/3;b=round(a,3);?b b = -0.667E0 |
half_down | round up if the digit >= 6 otherwise truncated. |
>$round=half_down;a=round(5.5555,3);?a a = 0.5555E1 |
ceil | round towards positive infinity(ceil). |
>$round=ceil;a=trim(1.2345,3);?a;b=trim(-1.2345,3);?b a = 0.124E1 b = -0.123E1 |
floor | round towards negative infinity(floor). |
>$round=floor;a=trim(1.2345,3);?a;b=trim(-1.2345,3);?b a = 0.123E1 b = -0.124E1 |
half_even | round towards the even neighbor(Banker's rounding). |
>$round=half_even >a=trim(2.125,3);?a a = 0.212E1 >a=trim(2.135,3);?a a = 0.214E1 |
Method | Description | Example |
---|---|---|
repeat n; | Statements after 'repeat n' to the line end will be repeated n times. n must be positive integer. | Factorial of 10(10!) >n=0;s=1;repeat 10;n=n+1;s=s*n >?s s = 0.36288E7 |
while a op b; | Statements after 'while a op b' to the end of line will be repeated while the condition 'a op b' is satisfied(true). a or b must be a variable or any numerical number.
One of a or b must be a variable at least. op can be the one listetd bellow.
|
Factorial of 10(10!) >n=10;s=1;while n>0;s=s*n;n=n-1 >?s s = 0.36288E7 |
if a op b; | If the condition 'a op b' is satisfied,then all statements to the end of line followed will be executed,otherwise skipped. 'break' can be followed by the 'if' to stop execution followed and exit iteration if it is executing. |
Factorial of 10(10!) >n=0;s=1;repeat 100;n=n+1;s=s*n;if n>=10;break >?s s = 0.36288E7 |
load 'file' V1 V2 ... Vn | Opens 'file', and reads all lines from the file. After reading each one line,numerical values(which VPC can regard as it is a numeric) in the line will be stored to the variables listed from left to right. So every line must contain n numerics at least. Any numeric after n-th position will be ignored. |
Contents of 'data.txt' 1 a2 b 2 ;;3 4 5 6 '-11' ( 12) - 13;; 21,, 22 ,23 Execution results >load data.txt a b c;?a;?b;?c a = 0.1E1 b = 0.2E1 c = 0.3E1 a = -0.11E2 b = 0.12E2 c = -0.13E2 a = 0.21E2 b = 0.22E2 c = 0.23E2 |
Setting name | Description | Example |
---|---|---|
$format |
Controls how the numeric number is printed. Each character of the character string at the right hand of $format will be processed from left to right. >?$format # default value $format = '10*E q'
|
Default value: '10*E q' >a=(1/3)*1000;?a a = 0.3333333333 3333333333 ... 333 333E3 >$format='QF,';?a a = '333.3333333333,33333...333,3333333333' |
$max_iterations | maximum number of iteration count for computing sin() cos() ...etc. | Default value: 10000 |
$precision | Maximum number of digits that each variable a,b,...z can hold. In case like a=b*c+d,the right hand side of the equation will be performed as many digits as to keep the exact result(computation like 1/3 is a special case ). And finaly rounded when stored to the left hand side variable when the total digits are greater than $precision according to the $round specification. | Default value: 100 |
$round | Method for the rounding operation. | Default value: half_up |
$title | Any character string can be specified. | Default value: "" |
$a,$b,...$y,$z | Any character string can be specified. Any comments about each variable may be useful. | Default value: "" |
I/O statement | Description |
---|---|
read 'file path' | Specified file is read and executed. If the file is output by 'write' command,then everything will be restored to the state when the 'write' command is executed. |
write 'file path' | Every value of variables and environment setting will be output to the specified file. Every thing can be restored by read command to the state when write is executed. |