1-Argument Operators

Home, Up: Operators and Constants

 

1-argument operators replace their argument (the value to their left) and themselves with the result of the operation.

 

On this page:

Arithmetic Operators, Trigonometric Operators, "IS" Operators, Measurement Unit Conversion Operators, Large Number Units, Notes.

 

Arithmetic Operators

SQ means "square": 3 SQ = 9

SQRT means "square root": 9 SQRT = 3

CUBE means "cube": 3 CUBE = 27

CBRT means "cubic root" (argument can be negative): -27 CBRT = -3

LN means "natural logarithm": 100 LN = 4.605...

LOG10 means "logarithm base 10": 100 LOG10 = 2

LOG2 means "logarithm base 2": 64 LOG2 = 6

EXP means "e to the power of ...": 2 EXP = 7.389...

EXP10 means "10 to the power of ...": 2 EXP10 = 100

EXP2 means "2 to the power of ...": 6 EXP2 = 64

! means "factorial" (argument must be 0 or positive integer, max. 449): 4 ! = 24

RCP means "reciprocal value": 5 RCP = 0.2

+- means "invert sign": 3 +- = -3

ABS means "absolute value": -3 ABS = 3

SIGN means "sign (+1, 0 or -1)": -3 SIGN = -1

INT means "integer part": 3.25 INT = 3

FRAC means "fractional part": 3.25 FAC = 0.25

DIGITS means "number of digits before or number of zeros after decimal point": 27.3 DIGITS = 2, 0.00273 DIGITS = -2

 

Trigonometric Operators

Regarding angles, Hypatia can be in "degrees" or in "radians" mode. Radians mode is default. The commands USE DEG and USE RAD set "degrees" or "radians" mode.

For more on this topic, see chapter "Numbers", page "Angles".

RAD means "convert degrees to radians": 180 RAD = 3.141...

DEG means "convert radians to degrees": PI DEG = 180 (Hypatia knows the constant PI)

SIN means "sine"

COS means "cosine"

TAN means "tangent"

ASIN means "arcsine"

ACOS means "arccos"

ATAN means "arctangent"

 

"IS" Operators

The result of an "is" operator is 1 if the statement about its argument is true, and 0 if it is false.

In most cases "is" operators will be used in scripts, and their argument will be a variable or a numerical expression.

IS0 means "is zero": 0.3 IS0 = 0

ISNOT0 means "is not zero": -0.3 ISNOT0 = 1

IS+ means "is positive": 0 IS+ = 0

IS+0 means "is positive or zero": 0 IS+0 = 1 (you can also write IS0+)

IS- means "is negative": 0 IS- = 0

IS-0 means "is negative or zero": 0 IS-0 = 1 (you can also write IS0-)

ISPOSINT means "is positive integer": 3 ISPOSINT = 1

ISPRIME means "is prime number": 13 ISPRIME = 1

 

Measurement Unit Conversion Operators

The names of all unit conversion operators begin with a colon. They work the same as other operators.

:F means "convert degrees Celsius to Fahrenheit"

:C means "convert degrees Fahrenheit to Celsius"

:MI means "convert km to international miles"

:KM means "convert international miles to km"

:NAUTMI means "convert km to nautical miles", or "convert km/h to knots"

:NAUTKM means "convert nautical miles to km", or "convert knots to km/h"

:IN means "convert cm to inches"

:CM means "convert inches to cm"

:FT means "convert meter to feet" (1 ft = 12 in)

:M means "convert feet to meter" (1 ft = 12 in)

:LB means "convert kg to avoirdupois pounds"

:KG means "convert avoirdupois pounds to kg"

:OZ means "convert g to avoirdupois ounces" (1 lb = 16 oz)

:G means "convert avoirdupois ounces to g" (1 lb = 16 oz)

:TOZ means "convert g to troy ounces"

:TG means "convert troy ounces to g"

:GAL means "convert liters to US liquid gallons"

:L means "convert US liquid gallons to liters"

:MPG means "convert miles per gallon to liters per 100km", and also "convert liters per 100km to miles per gallon"

 

Large Number Units

LAKH means "multiply value by one hundred thousand" (Indian numbering system): 3.1 LAKH = 310000

MILLION means "multiply value by one million": 3.1 MILLION = 3100000

CRORE means "multiply value by ten million" (Indian numbering system): 3.1 CRORE = 31000000

 

"Large number units" work like 1-argument operators: 2 1 MILLION + = 1000002, 2 1 + MILLION = 3000000

They differ from other 1-argument operators in two ways:

- you can use them in MAXLOOP n, DO n and REPEAT n commands

- you can use them after numbers at the beginning of lines in chain calculations

Example:

? 3

= 3

? MILLION

= 3'000'000

? 2 MILLION +

= 5'000'000

 

Notes

SIN and COS round results less than plus/minus 1e-18 to zero.

TAN requires absolute value of argument to be less than pi/2 or 90 degrees.

Do not confuse the RAD and DEG operators with the USE DEG and USE RAD commands!

The zero threshold applies to SIGN and to the "is" operators IS0, ISNOT0, IS+, IS+0, IS- and IS-0.

FRAC rounds its result to a total of 18 digits of the argument because more decimal digits would be random, and then down to 0.999999999999999 (15 digits) if it is larger, to avoid the result 1.

 

Home, Up: Operators and Constants, Next: 2-Argument Operators