Units

An overview of available unit types in Stof.

Stof has units as primitive types. Each unit type is a variant of a floating-point number, able to do unit conversions when used in operations or explicitly cast to another unit type.

See Primitive Types to learn more about the value types Stof has available.

Outlined on this page is an overview of all of the unit types Stof has available. Unit conversions can happen with units of the same category.

Reference Table

Category
Unit
Stof Type Keywords

Length

Kilometers

km, kilometer, kilometers

Length

Hectometers

hm, hectometer, hectometers

Length

Decameters

dcm, decameter, decameters

Length

Meters

m, meter, meters

Length

Decimeters

dm, decimeter, decimeters

Length

Centimeters

cm, centimeter, centimeters

Length

Millimeters

mm, millimeter, millimeters

Length

Micrometers

um, micrometer, micrometers

Length

Nanometers

nm, nanometer, nanometers

Length

Miles

mi, mile, miles

Length

Yards

yd, yard, yards

Length

Feet

ft, foot, feet

Length

Inches

in, inch, inches

Time

Days

day, days

Time

Hours

hr, hrs, hour, hours

Time

Minutes

min, mins, minute, minutes

Time

Seconds

s, second, seconds

Time

Milliseconds

ms, millisecond, milliseconds

Time

Microseconds

us, microsecond, microseconds

Time

Nanoseconds

ns, nanosecond, nanoseconds

Temperature

Kelvin

K, kelvin, Kelvin

Temperature

Celsius

C, celsius, Celsius

Temperature

Fahrenheit

F, fahrenheit, Fahrenheit

Mass

Gigatonnes

Gt, gigatonne, gigatonnes

Mass

Megatonnes

Mt, megatonne, megatonnes

Mass

Tonnes

t, tonne, tonnes

Mass

Kilograms

kg, kilogram, kilograms

Mass

Grams

g, gram, grams

Mass

Milligrams

mg, milligram, milligrams

Mass

Micrograms

ug, microgram, micrograms

Mass

Nanograms

ng, nanogram, nanograms

Mass

Picograms

pg, picogram, picograms

Mass

Tons (US imperial)

ton, tons, Ton, Tons

Mass

Pounds (US imperial)

lb, lbs, pound, pounds

Mass

Ounces (US imperial)

oz, ounce, ounces

Angle

Radians

rad, radians

Angle

Degrees

deg, degrees

Angle

Positive Radians

prad, pradians

Angle

Positive Degrees

pdeg, pdegrees

Length Units

Kilometers

Stof type keywords:

  • km

  • kilometer

  • kilometers

Hectometers

Stof type keywords:

  • hm

  • hectometer

  • hectometers

Decameters

Stof type keywords:

  • dcm

  • decameter

  • decameters

Meters

Stof type keywords:

  • m

  • meter

  • meters

Decimeters

Stof type keywords:

  • dm

  • decimeter

  • decimeters

Centimeters

Stof type keywords:

  • cm

  • centimeter

  • centimeters

Millimeters

Stof type keywords:

  • mm

  • millimeter

  • millimeters

Micrometers

Stof type keywords:

  • um

  • micrometer

  • micrometers

Nanometers

Stof type keywords:

  • nm

  • nanometer

  • nanometers

Miles

Stof type keywords:

  • mi

  • mile

  • miles

Yards

Stof type keywords:

  • yd

  • yard

  • yards

Feet

Stof type keywords:

  • ft

  • foot

  • feet

Inches

Stof type keywords:

  • in

  • inch

  • inches

Time Units

Days

Stof type keywords:

  • day

  • days

Hours

Stof type keywords:

  • hr

  • hrs

  • hour

  • hours

Minutes

Stof type keywords:

  • min

  • mins

  • minute

  • minutes

Seconds

Stof type keywords:

  • s

  • second

  • seconds

Milliseconds

Stof type keywords:

  • ms

  • millisecond

  • milliseconds

Microseconds

Stof type keywords:

  • us

  • microsecond

  • microseconds

Nanoseconds

Stof type keywords:

  • ns

  • nanosecond

  • nanoseconds

Temperature Units

Kelvin

Stof type keywords:

  • K

  • kelvin

  • Kelvin

Celsius

Stof type keywords:

  • C

  • celsius

  • Celsius

Fahrenheit

Stof type keywords:

  • F

  • fahrenheit

  • Fahrenheit

Mass Units

Gigatonnes

1e15 grams.

Stof type keywords:

  • Gt

  • gigatonne

  • gigatonnes

Megatonnes

1e12 grams.

Stof type keywords:

  • Mt

  • megatonne

  • megatonnes

Tonnes

1e6 grams.

Stof type keywords:

  • t

  • tonne

  • tonnes

Kilograms

1e3 grams.

Stof type keywords:

  • kg

  • kilogram

  • kilograms

Grams

Stof type keywords:

  • g

  • gram

  • grams

Milligrams

1e-3 grams.

Stof type keywords:

  • mg

  • milligram

  • milligrams

Micrograms

1e-6 grams.

Stof type keywords:

  • ug

  • microgram

  • micrograms

Nanograms

1e-9 grams.

Stof type keywords:

  • ng

  • nanogram

  • nanograms

Picograms

1e-12 grams.

Stof type keywords:

  • pg

  • picogram

  • picograms

Tons

US imperial mass unit, defined as 0.907 tonnes.

Stof type keywords:

  • ton

  • tons

  • Ton

  • Tons

Pounds

US imperial mass unit, defined as 453.592 grams.

Stof type keywords:

  • lb

  • lbs

  • pound

  • pounds

Ounces

US imperial mass unit, defined as 28.3495 grams.

Stof type keywords:

  • oz

  • ounce

  • ounces

Angle Units

For operations, base units for angles are always radians. For comparisons and equality, angles get cast to positive radians, with a precision of 1e-6.

Angles are always clamped between 0 and 360 degrees. Radians and Degrees can be +-360deg, but Positive Radians and Positive Degrees treat 360deg as 0deg and always remain positive.

If you need angles expressed differently, you can always use a normal floating-point number.

Radians

Clamped between [0, +-2pi].

Stof type keywords:

  • rad

  • radians

Degrees

Clamped between [0, +-360].

Stof type keywords:

  • deg

  • degrees

Positive Radians

Clamped between [0, +2pi).

Stof type keywords:

  • prad

  • pradians

Positive Degrees

Clamped between [0, +360).

Stof type keywords:

  • pdeg

  • pdegrees

Last updated