|
| |
!SetCalc
Description
Performing calculations from the command line
Contents
The builtin Common Command Set contains only one command to perform mathematical calculations. The "SET
/A" command can work directly with whole numbers from
-2,147,483,647 up to +2,147,483,647.
This allows for a wide variety of functions using some creative offsets. The table below shows a few of the calculations that are within the numeric range of the builtin command. When
performing any calculation, any fractional component is dropped from the result. This has the effect of always rounding DOWN to the nearest whole integer.
In each row, starting with the value in green, you can successfully calculate any of the values to it's right in that row using only
SET /A commands at the command line or in a script.
|
TIME |
Seconds |
Minutes |
Hours |
Days |
Weeks |
Months |
Years |
Decades |
| |
2,147,483,647 |
35,791,394 |
596,523 |
24,855 |
3,550 |
814 |
67 |
6 |
| |
|
2,147,483,647 |
35,791,394 |
1,491,308 |
213,044 |
49,029 |
4,085 |
408 |
| |
|
|
2,147,483,647 |
89,478 |
12,782 |
2,940 |
245 |
24 |
| |
|
|
|
2,147,483,647 |
306,783,378 |
70,602,202 |
5,883,516 |
588,351 |
| |
Nanoseconds
(Billionths) |
Microseconds
(Millionths) |
Milliseconds
(Thousandths) |
Centiseconds
(Hundredths) |
Deciseconds
(Tenths) |
Seconds |
Minutes |
Hours |
| |
2,147,483,647 |
2,147,483 |
2,147 |
214 |
2 |
|
|
|
| |
|
2,147,483,647 |
2,147,483 |
2,147 |
214 |
2 |
|
|
| |
|
|
2,147,483,647 |
214,748,364 |
21,474,836 |
2,147,483 |
35,791 |
596 |
| |
|
|
|
2,147,483,647 |
214,748,364 |
21,474,836 |
357,913 |
5,965 |
| |
|
|
|
|
2,147,483,647 |
214,748,364 |
3,579,139 |
59,652 |
|
SIZE |
Bits |
Bytes |
Kilobytes |
Megabytes |
Millions of Bytes |
Gigabytes |
GB (1000MB) |
Terabytes |
| |
2,147,483,647 |
268,435,455 |
262,143 |
255 |
268 |
0 |
0 |
0 |
| |
|
2,147,483,647 |
2,097,151 |
2,047 |
2,147 |
1 |
2 |
0 |
| |
|
|
2,147,483,647 |
2,097,151 |
2,199,023 |
2,047 |
2,097 |
1 |
| |
|
|
|
2,147,483,647 |
|
2,097,151 |
2,147,483 |
2,047 |
| |
|
|
|
|
2,147,483,647 |
1,999,999 |
2,047,999 |
1,953 |
|
DISTANCE
(US) |
1/16 Inch |
1/8 Inch |
1/4 Inch |
1/2 Inch |
Inches |
Feet |
Yards |
Miles |
| |
2,147,483,647 |
1,073,741,823 |
536,870,911 |
268,435,455 |
134,217,727 |
11,184,810 |
3,728,270 |
2,118 |
| |
|
2,147,483,647 |
1,073,741,823 |
536,870,911 |
268,435,455 |
22,369,621 |
7,456,540 |
4,236 |
| |
|
|
2,147,483,647 |
1,073,741,823 |
536,870,911 |
44,739,242 |
14,913,080 |
8,473 |
| |
|
|
|
2,147,483,647 |
1,073,741,823 |
89,478,485 |
29,826,161 |
16,946 |
| |
|
|
|
|
2,147,483,647 |
178,956,970 |
59,652,323 |
33,893 |
| |
|
|
|
|
|
2,147,483,647 |
715,827,882 |
406,720 |
|
DISTANCE
(Metric) |
Picometers |
Nanometers |
Micrometers |
Millimeters |
Centimeters |
Meters |
Kilometers |
Nautical
Miles |
| |
2,147,483,647 |
2,147,483 |
2,147 |
2 |
|
|
|
|
| |
|
2,147,483,647 |
2,147,483 |
2,147 |
214 |
2 |
|
|
| |
|
|
2,147,483,647 |
2,147,483 |
214,748 |
2,147 |
2 |
1 |
| |
|
|
|
2,147,483,647 |
214,748,364 |
2,147,483 |
2,147 |
1,159 |
| |
|
|
|
|
2,147,483,647 |
21,474,836 |
21,474 |
11,595 |
| |
|
|
|
|
|
2,147,483,647 |
2,147,483 |
1,159,548 |
|
MONEY
(US) |
Pennies |
Nickels |
Dimes |
Quarters |
Dollars |
$1000 |
$1M |
$1B |
| |
2,147,483,647 |
429,496,729 |
214,748,364 |
85,899,345 |
21,474,836 |
21,474 |
21 |
2 |
| |
Dollars |
$Hundreds |
$Thousands |
$Millions |
$Billions |
$Trillions |
$Quadrillions |
|
| |
2,147,483,647 |
21,474,836 |
2,147,483 |
2,147 |
2 |
|
|
|
| |
|
2,147,483,647 |
214,748,364 |
214,748 |
214 |
|
|
|
| |
|
|
2,147,483,647 |
2,147,483 |
2,147 |
2 |
|
|
| |
|
|
|
2,147,483,647 |
2,147,483 |
2,147 |
2 |
|
For a practical example of using offsets to your advantage, see the
.GetFreeM
and
.GetDirSizeM commands. The
M stands for Millions of bytes (1,000,000 - not 1,048,576). This allows us to process directory sizes and free space up to over 2,000 TB in a shell
script using only native commands and utilities.
Related .Mount/\Commands, #Constants,
$Functions, :Procedures
|
Resource |
|
Short Description |
|
GetFree |
|
Displays the available space, in Millions of bytes, on the current drive |
|
GetFreeM |
|
Displays the available space, in bytes, on the current drive |
|
GetDirSize |
|
Displays
the size, in bytes, of the current directory |
|
GetDirSizeM |
|
Displays
the size, in Millions of bytes, of the current directory |
|
K
E
Y |
Common Commands |
INTERNAL |
External |
/SWITCH |
Parameter |
Help text |
AddonTool |
|
Mounted Commands |
.Mount/\Command |
CmdShorthand |
#Constant |
$FUNCTION |
:Procedure |
!GuardNote |
|
Operating Systems |
NT/2K/XP/K3 |
NT Only |
NT/2K |
2K Only |
2K/XP |
XP Only |
XP/K3 |
K3 Only |
2K/XP/K3 |
|