News for hackers. Stuff that matters.
Re:Show HN: I created Units Converter that contains 5000 uni... by ocrow on Wednesday June 21, 2023 @01:05PM (#36421256)
You could add GeV/c2 (giga-electronvolts per speed of light squared) as a unit of weight that is used by physicists for sub-atomic particle mass.
Re:Show HN: I created Units Converter that contains 5000 uni... by chrismorgan on Wednesday June 21, 2023 @01:30PM (#36421629)
As an example of a completely different approach, this works out of the box in GNU units (showing both noninteractive and interactive usage):

  $ units GeV/c^2
          Definition: 1.7826619e-27 kg

  $ units
  Currency exchange rates from FloatRates (AUD base) on 2023-06-21
  3761 units, 113 prefixes, 120 nonlinear units

  You have: GeV/c^2
  You want: [leave it blank]
          Definition: 1.7826619e-27 kg
  You have: 
Because of these various definitions (a selection of lines pulled from /usr/share/units/definitions.units, I think I have included all the relevant ones recursively):

  G-                      giga
  giga-                   1e9      # Greek gigas, "giant"
  e         1.602176634e-19 C  # electron charge (exact)
  C                       coulomb
  coulomb                 A s          # charge
  A         !      # The ampere, symbol A, is the SI unit of electric current. […]
  s         !      # The second, symbol s, is the SI unit of time.  It is defined […]
  V                       volt
  volt                    W/A          # potential difference
  W                       watt
  watt                    J/s          # power
  J                       joule
  joule                   N m          # energy
  N                       newton
  newton                  kg m / s^2   # force
  kg        !      # The kilogram, symbol kg, is the SI unit of mass.  It is […]
  m         !      # The metre, symbol m, is the SI unit of length.  It is […]
  c         299792458 m/s   # speed of light in vacuum (exact)
(Fun thing, kg being the SI unit. Because of this, gram is defined as millikg!)

I really like the approach of specifying what you have, in absolutely whatever unit you like, and what you want (though I omitted that argument in this case, to just have it show the definition), and having it resolve it.

An excerpt from my ~/.units (which does have some serious stuff in it too, honest):

  # Why not? (Question: is the slightly-Welsh-sounding ygazillion, yocto-gazillion, 10⁻²⁴ gazillion, greater or less than one?)
  gazillion !

  elephant 6.35 tonne
  elephant_african 6.35 tonne
  elephant_asian 5 tonne
  # I want to have ranged values: elephant_baby 90–135 kg. This get complicated because of non-linear transformations, e.g. 2^(1–10) = 2–1024, but log₂-biased.
  # baby_grand is also a baby
Re:Show HN: I created Units Converter that contains 5000 uni... by KodyBerns99 on Wednesday June 21, 2023 @01:10PM (#36421352)
Thank you, I will definitely add it.