Skip to content

List of constants and unit conversion factors

43615 edited this page Dec 19, 2023 · 52 revisions

Explanation

Technical

  • This list only applies to this implementation and is not a hard specification.
  • Number objects aren't stored in the library directly, but are instead created on demand using the current working precision. The hard-coded values are rationals, which allows for creating floats with arbitrary precision.
  • 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).

Unit conversion

  • Unit conversion doesn't happen automatically, the " command only creates a conversion factor in respect to the standard unit of the dimension (in bold).
    • To convert from a different unit to the standard one, multiply by the factor.
    • To convert from the standard unit to a different one, divide by the factor.
  • Combined syntax for unit conversion: [from to]"* (exactly one space).
  • Signed integers at the beginning of unit names are interpreted as scale prefixes (10ⁿ).
    • Using numbers instead of the standard SI prefixes avoids ambiguity about the presence and extent of prefixes (for instance, min could be minutes or milli-inches) and allows arbitrary scaling where no official prefixes are specified.
  • Unsigned integers at the end of unit names are interpreted as powers (creating derived area and volume units).

Usage examples:

  • [phi]" pushes the golden ratio.
  • 90[deg]"* converts 90° to radians.
  • 80[lb]"/ converts 80 kilograms to pounds.
  • 3[6in nmi]"* converts 3 million inches to nautical miles.
  • 5[in3 -2m3]"* converts 5 cubic inches to cubic centimeters.
  • 69[w2 21tsp]"* converts 69 square weeks to zettateaspoons. Nonsense is possible, be careful.

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
  • mo: average month (30 d)
  • a: common year (365 d)
  • aj: Julian year (365.25 d)
  • ag: Gregorian year (365.2425 d)

Information units

Remember, decimal prefixes are expressed with numbers.

  • b..Qib: bit..quebibit
  • B..QiB: byte..quebibyte

Other units

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

Special values and functions

These are not necessarily constant!

  • inf: +∞
  • ninf: -∞
  • nan: NaN
  • time: current system time in seconds since the Unix epoch
  • timens: current system time in nanoseconds since the Unix epoch
    • Accuracy depends on system architecture and OS.
  • 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. They can be disabled with the safe toggle.

  • 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.