GNU Units
101–110 of 117 posts
Re: GNU Units
#102Earlier quoted context omitted.
Just for curiosity, what Nim does that other languages with operator overloading wouldn't do? Aside from the "number.unit" syntax, you could do some trickery to get units comparison and conversions even on C++
I work in large C++ codebase for a suite of physics simulation software, and there are like 200 something strongly typed arithmetic units here.
To be concrete (hah!), in C++ a template meta-type with 12 signed integer parameters (6 numerators & 6 denominators for rational exponents of SI base units) might be one way to model it.
Unlike C++ template stuff, Nim macros (like Lisp macros) makes metaprogramming more like procedural programming - just against abstract syntax trees. I think that helps to shield some of this type complexity from users, but the documentation README https://github.com/SciNim/Unchained does better job than I can in an HN comment.
Of course, for unit system conversion, the number of dimensions (6 in SI, 3 in CGS/Gaussian) changes. So, for full generality you need compile-time (if you want static type integration/CT errors) linear algebra over a rational field (at least & conventionally) to project|inverse project. That might be theoretically possible in C++. I would think it very un-fun and unlikely to ever have been done. There's probably a Mathematica package, though.
EDIT: It seems that mp-units mentioned in a sibling comment has some rare support for varying unit systems (no GR or Planck ones, but at least "natural" & "hep" & not sure about system-conversion or just system-use). That lib also leans very heavily on many very modern C++ (C++20 & beyond) features, has constexpr everywhere in use cases. I am not sure I would say it shields users wonderfully or makes it seem like units are very ordinary types. Just looking at mp-units/example/VARIOUS.cpp makes it look syntactically very noisy, verbose, and a lot to learn.
Re: GNU Units
#103When I run `sudo pacman -Fy units` on Arch Linux I only get a similar tool from plan9port, it's strange they took the GNU version out of the repos.
Without looking into it at all, it probably just didn't have an active package maintainer.
The original maintainer still maintains 2185 packages [2].
Can't find an explanation why though.
[0]: https://github.com/archlinux/svntogit-community/commit/2b5ec...
[1]: https://aur.archlinux.org/cgit/aur.git/commit/?h=units&id=e6...
Re: GNU Units
#104Re: GNU Units
#105IIRC, GNU Units was once the center of a small controversy. Google (still, AFAIK) offers unit conversion as a part of their search box; you can type a unit conversion into Google and get a conversion done. Some people noted this, wondered about what the backend might be, and typed some stuff in which was known to trigger a then-present bug in GNU Units. And wouldn’t you know it, Google showed the same bug. This was a…
Maybe the ripped out GNU Units. Never know, since they never distributed it.
Re: GNU Units
#106Earlier quoted context omitted.
Without looking into it at all, it probably just didn't have an active package maintainer.
The author of the AUR package, removed it from the community repo and moved it to the AUR. And now it has another maintainer in the AUR. The original maintainer still maintains 2185 packages [2]. Can't find an explanation why though. [0]: https://github.com/archlinux/svntogit-community/commit/2b5ec... [1]: https://aur.archlinux.org/cgit/aur.git/commit/?h=units&id=e6... [2]: https://archlinux.org/packages/?packager=ar…
Re: GNU Units
#107this page seriously undersells the versatility and utility of the units program how long will my laptop take to charge at its current rate of charging? You have: (22.8 Wh - 16.8 Wh)/7.4W You want: time 48 min + 38.918919 sec how long will a 2000mAh 18650 cell take to discharge at 2.5 watts, using a nominal voltage of 3.7 volts? You have: 3.7 V 2 amp hour / 2.5 watt You want: time 2 hr + 57 min + 36 sec what energy de…
Re: GNU Units
#108this page seriously undersells the versatility and utility of the units program how long will my laptop take to charge at its current rate of charging? You have: (22.8 Wh - 16.8 Wh)/7.4W You want: time 48 min + 38.918919 sec how long will a 2000mAh 18650 cell take to discharge at 2.5 watts, using a nominal voltage of 3.7 volts? You have: 3.7 V 2 amp hour / 2.5 watt You want: time 2 hr + 57 min + 36 sec what energy de…
This is an absolutely awesome comment. Thanks, kragen.
Re: GNU Units
#109It wasn't until a decade or so of using it that I realised it was actually a units-aware calculator, and could make interesting conversions (say: how much land area you'd need to supply all US energy needs with solar power, given various factors of incident sunlight, spacing factors, panel efficiencies, etc.). kragen's comment in this thread blows away my own usage (I learned several new things reading it, which means this is a Good Day).
Note for MacOS and *BSD users: the variant of units shipping on your systems is a parlously pale shadow of the GNU version. MacOS boffins can install GNU Units via Homebrew, where it's accessed as "gunits" by default.
Re: GNU Units
#110Demo: https://yanosh.net/units-wasm/ GitHub Repo for the demo: https://github.com/yanosh-k/units-wasm GitHub Repo for the WASM project: https://github.com/yanosh-k/gnu-wasmunits