|
This software can be redistributed under GNU Lesser General Public License.
Every source code of this software can be obtained through GitHub. Copylight (c) 2024 Shigeo Kobayashi. All rights reserved. Japanese |
VPC(Variable Precision Calculator V2) of Bigdecimal(V11) Copyright (c) 2024 by Shigeo Kobayashi. Allrights reserved. Enter command >a = pi(); a = 0.3141592653 5897932384 6264338327 9502884197 1693993751 0582097494 4592307816 4062862089 9862803482 5342117068 E1 >$precision = 200 >b = pi() b = 0.3141592653 5897932384 6264338327 9502884197 1693993751 0582097494 4592307816 4062862089 9862803482 5342117067 9821480865 1328230664 7093844609 5505822317 2535940812 8481117450 2841027019 3852110555 9644622948 9549303819 6E1 >c = a-b c = 0.1785191348 6717693352 9061553904 4941776827 4640591871 5188825497 1589729806 1478894440 3553770510 4506961804 E-100
Download all necessary files compressed to the single file 'bigdecimal_win.zip'(contains 32bit 'exe' and 'dll').Other OS(LINUX etc):
And extract all files to any folder prepared for VPC. And just run vpc.exe.
If you place the short cut of vpc.exe on the desk top,select 'vpc.bmp' for VPC icon.
Download all files including source files from GitHub.
Refer to the contents of the downloaded 'makefile', compile(build) necessary files, and install executables(and others) according to your OS by hand.
?? ... prints help messages.
?* ... prints value of all variables and environment settings.
?$ ... prints all environment settings.
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 quoted numerical expression are ignored.
! dir !"dir *.txt"
| Function name | Description | Example | Remarks |
|---|---|---|---|
| atan(a) | computes arctangent of a c = tan-1(a) |
>a=atan(0.5) a = 0.4636476090 0080611621 ... 5653E0 | |a|<=1 |
| sin(a)/cos(a) | computes trigonometric function |
>a=sin(1);b=cos(1);c=a*a+b*b 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 = 0.2718281828 4590452353 ... 4E1 | |
| ln(a) | computes natural logarithm(base of Napier's number). | >a=ln(0.5);b=exp(a) a = -0.6931471805 5994530941 723... 42E0 b = 0.5E0 | 0 < a <= 2 |
| pi() | computes ratio of a circle's circumference(π). | >a=pi() a = 0.3141592653 5897932384 ...068 E1 | brackets () are necessary. |
| sqrt(a) | computes square root a=b1/2 | >a=sqrt(5) a = 0.2236067977 4997896964 ...275 E1 | a >= 0 |
| iterations() | returns total number of iteration count done just before. | >a=sqrt(2);b=iterations() 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=abs(-1) a = 0.1E1 | |
| power(a,n) | computes n power of a b=power(a,n) => b=an | >a=power(2,-2) a = 0.25E0 | n must be a positiove or negative integer. a = power(2,0.5) is an error. |
| int(a) | extracts integer part of a. | >a=int((1/3)*100) a = 0.33E2 | |
| frac(a) | extracts fraction part of a. | >a=frac((1/3)*100) a = 0.3333333333 3333333333 ... 33 E0 | |
| digits(a) | returns number of effective digits of a. | >a=(1/3)*2;b=digits(a) a = 0.6666666666 6666666666 ... 666 6667E0 b = 0.104E3 | |
| exponent(a) | returns an integer number of exponent of a. a=0.xxxx*10nexponent(a) returns n. | >a=power(10,3);b=exponent(a) 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. | >?$round $round = 'half_up' >$format=F >a=1234.5678 a = 1234.5678results of trim() and round() are bellow. |
| 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. | >b=trim(a,4);c=round(a,1);d=round(a,-1);e=round(a,0) b = 1235 c = 1234.6 d = 1230 e = 1235 |
| Round method | Meaning | Example |
|---|---|---|
| up | round away from zero. | >$round=up;a=round(-1/3,0) a = -0.1E1 |
| down | round towards zero(truncate). | >$round=down;a=round(-1/3,0) a = -0.0 |
| half_up | round up if the digit >= 5 otherwise truncated(default). | >a=round(-2/3,3) a = -0.667E0 |
| half_down | round up if the digit >= 6 otherwise truncated. | >$round=half_down;a=round(5.5555,3) a = 0.5555E1 |
| ceil | round towards positive infinity. | >$round=ceil;a=trim(1.2345,3);b=trim(-1.2345,3) a = 0.124E1 b = -0.123E1 |
| floor | round towards negative infinity. | >$round=floor;a=trim(1.2345,3);b=trim(-1.2345,3) 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 = 0.212E1 >a=trim(2.135,3) 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 $format = '10*E q' # Default setting
|
>?$format $format = '10*E q' # Default value >a=123456789012345 a = 0.1234567890 12345E15 >$format = 5 >?a a = 0.12345 67890 12345 E15' >$format=+ >?a a = +0.12345 67890 12345 E15 >$format=, >?a a = +0.12345,67890,12345,E15 >$format=Q >?a a = '+0.12345,67890,12345,E15' >$format = F;?a a = '+12345,67890,12345' >?$format $format = '5+F,Q' >$format = " " >?$format $format = '5+F Q' |
| $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. |
a = -1*0; ?a # => a = -0 b = 1*0; ?b # => b = 0 c = a*b; ?c # => c = -0 $d = "0 == -0" if a==b; ?$d # => "0 == -0"