Skip to content

List of constants and unit conversion factors

43615 edited this page Jul 20, 2022 · 52 revisions
  • All constants are calculated on-demand according to the current working precision. All hard-coded "raw" values are exact.
  • Where applicable, constants are stored in amounts of their respective international standard units.
  • Physical constants for which the exact value isn't determined are provided with the currently accepted precision (2022).
  • Units in bold are the standard units for their dimension (return 1) and may be omitted when converting (see readme for examples).
  • Simplified notation for unit conversion: [oneunit otherunit]"* (exactly one space).
  • Signed integers at the beginning of unit names are removed and applied as scale prefixes (10ⁿ).
    • Using explicit numbers instead of the standard SI prefixes resolves ambiguity and allows for arbitrary scaling.
  • Unsigned integers at the end of unit names are removed and applied as powers (creating derived area and volume units).
  • Valid unit names match ^-?\d*[a-zA-Z°]+\d*$.

Mathematical constants

  • e: Euler's number, 2.7182818284...
  • pi: π, 3.1415926535...
  • gamma: Euler-Mascheroni constant, 0.5772156649...
  • phi: golden ratio, 1.6180339887...
  • deg or °: 1 degree in radians, π/180
  • gon or grad: 1 gon/gradian in radians, π/200

Physical constants

  • c: speed of light, 299792458 m/s
  • hbar: reduced Planck constant, 6.62607015*10⁻³⁴/2π Js
  • G: Newtonian gravitational constant, 6.674*10⁻¹¹ Nm²/kg²
  • qe: elementary charge, 1.602176634*10⁻¹⁹ C
  • NA: Avogadro's number, 6.02214076*10²³ mol⁻¹
  • kB: Boltzmann constant, 1.380649*10⁻²³ J/K
  • u: Dalton/atomic mass unit, 1.660539066*10⁻²⁷ kg
  • lp: Planck length, 1.6162*10⁻³⁵ m
  • tp: Planck time, 5.391*10⁻⁴⁴ s
  • mp: Planck mass, 2.1764*10⁻⁸ kg
  • Tp: Planck temperature, 1.4167*10³² K

Length units

  • m: meter
  • in: inch
  • ft: foot
  • yd: yard
  • mi: mile
  • nmi: nautical mile
  • AU: astronomical unit
  • ly: light year
  • pc: parsec

Area and volume units with no length equivalent

  • ac or acre: acre
  • l: liter

Imperial and US units

Sad fact: The non-metric volume systems aren't even unified! Identical names are distinguished with the prefixes i and u.

Imperial system

  • ifloz: fluid ounce
  • ipt: pint
  • iqt: quart
  • igal: gallon
  • ibu or ibsh: bushel

US liquid system

  • ufldr: fluid dram
  • tsp: teaspoon
  • tbsp: tablespoon
  • ufloz: fluid ounce
  • upt: pint
  • uqt: quart
  • ugal: gallon
  • bbl: oil barrel

US dry system

  • udpt: dry pint
  • udqt: dry quart
  • udgal: dry gallon
  • ubu or ubsh: bushel
  • dbbl: dry barrel

Mass units

  • kg: kilogram
    • Unfortunately, the gram is not the primary international standard unit. Be careful about that (ng = -12kg).
  • ct: carat
  • oz: ounce
  • lb: pound
  • st: stone

Time units

  • s: second
  • min: minute
  • h: hour
  • d: day
  • w: week
  • There are no "month" or "year" values since these units aren't well-defined (28-31 days per Gregorian calendar month; 365, 365.25, 365.2425 or 365.2421???? days per year depending on definition).

Other units

  • J: joule
  • cal: calorie (thermochemical)
  • Pa: pascal
  • atm: atmosphere
  • psi: pound per square inch

Special values and functions

These are not necessarily constant!

  • time: current system time in seconds since the Unix epoch
  • timens: current system time in nanoseconds since the Unix epoch
    • Might have less precision on some platforms.
  • pid: OS-assigned process ID of this dc:im instance
  • author: 43615

Terminating functions

Instead of returning a number, the following unit names cause dc:im to exit abnormally.

  • abort terminates this dc:im instance, indicating "abnormal" behaviour to the OS.
  • crash crashes this dc:im instance by intentionally overflowing the call stack.
  • panic panics this dc:im instance. If the top-of-stack is a string, it is returned as the panic message.
Clone this wiki locally