News for hackers. Stuff that matters.
Re:GNU Units by kragen on Thursday August 03, 2023 @01:26PM (#36988917)
this 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 thick of a cable do i need to support me (or, from a different point of view, to pose a risk of accidental strangulation)? suppose its tensile strength is 2.7 gigapascals

    You have: 120kg gravity / 2.7 GPa
    You want: mm2
            * 0.43585111
            / 2.2943615
    You have: _
    You want: circlearea
            0.00037247244 m
    You have: _
    You want: mm
            * 0.37247244
            / 2.6847624
note that this is the radius of the cable, not its diameter!

how much power would this 400×240 display use if i overclock it to 60 fps and it uses 1.3 nanojoules per pixel update?

    You have: 60 Hz 400 240 1.3nJ
    You want: μW
            * 7488
            / 0.00013354701
what is the visual angle subtended by the sun as seen from earth?

    You have: 2 sunradius/sundist
    You want: milliradians
            * 9.3049358
            / 0.10746984
    You have: _
    You want: dms
            31 arcmin + 59.280781 arcsec
okay, how does that compare to the moon?

    You have: moonradius 2 / moondist
    You want: 
            Definition: 0.0090426639
on average the moon looks a little smaller, which is why annular eclipses are so common, but we can also calculate that total eclipses are possible because sometimes the moon looks bigger

    You have: moonradius 2 / moondist_min
    You want: 
            Definition: 0.0097530864
what's the energy density of stoichiometrically mixed oxyhydrogen fuel?

    You have: 44000 J/mol / ((2 hydrogen + oxygen)g/mol)
    You want: MJ/kg
            * 2.4423711
            / 0.40943818
how much energy can this capacitor hold?

    You have: half (10V)**2 47 uF
    You want: mJ
            * 2.35
            / 0.42553191
how much energy density is that?

    You have: half (10V)**2 47 μF / 15mm circlearea(3mm)
    You want: J/ℓ
            * 5.5409499
            / 0.18047447

(to be continued)
Re:GNU Units by chungy on Thursday August 03, 2023 @02:31PM (#36989791)
Trying your examples, especially considering that the elliptical orbit of the earth likewise causes the Sun's angular diameter change depending on where our orbit is, I found that Units current has a buggy definition of moondist_min and moondist_max. It's defined in the definitions file as 356.371 km and 406.720 km respectively. These should be Mm! (Or remove the period, either will work)

Just to work around the bug, you can use a local definitions file to correct it:

    cat > ~/.units <<EOF
    moondist_min 356.371 Mm
    moondist_max 406.720 Mm
    EOF
Re:GNU Units by kragen on Thursday August 03, 2023 @03:03PM (#36990254)
interesting, looks like an effort to improve the precision resulted in a factor of 1000 error! `help moondist_max` shows me considerably less precise values:

    sundist                 1.0000010178 au # mean earth-sun distance
    moondist                3.844e8 m       # mean earth-moon distance
    sundist_near            1.471e11 m      # earth-sun distance at perihelion
    sundist_far             1.521e11 m      # earth-sun distance at aphelion
    moondist_min            3.564e8 m       # approximate least distance at
                                            #    perigee 1901-2300
    moondist_max            4.067e8 m       # approximate greatest distance at
                                            #    apogee 1901-2300
Re:GNU Units by chungy on Thursday August 03, 2023 @05:24PM (#36992165)
Where are you typing help to get that output?
Re:GNU Units by kragen on Thursday August 03, 2023 @05:35PM (#36992297)
at the units prompt

    You have: help moondist_max
then i scrolled up a few lines in less
Re:GNU Units by chungy on Thursday August 03, 2023 @05:49PM (#36992472)
I could've sworn I tried and didn't get anything. Now it is working. I don't know what I did! (running version 2.22, at any rate)
Re:GNU Units by kragen on Thursday August 03, 2023 @06:48PM (#36993135)
sweet

search is also pretty nice

    You have: search gallon
    alegallon      beergallon
    beergallon     282 UKinch^3
    brgallon       4.54609 l
    drygallon      1|2 uspeck
    gallon         usgallon
    imperialgallon brgallon
    irishgallon    217.6 UKinch^3
    scotsgallon    827.232 UKinch^3
    usgallon       231 in^3
    winegallon     231 UKinch^3
Re:GNU Units by DakotaR on Thursday August 03, 2023 @10:02PM (#36994551)
Thank you, these examples are amazing
Re:GNU Units by kragen on Thursday August 03, 2023 @10:47PM (#36994894)
i'm glad you like them
Re:GNU Units by klysm on Saturday August 05, 2023 @02:16AM (#37009464)
Impressive list. The maintainers should copy paste this onto that page
Re:GNU Units by kragen on Sunday August 06, 2023 @01:52PM (#37024677)
they have my permission

everyone is free to redistribute my comment, in whole or in part, modified or unmodified, with or without credit; i waive all rights associated with it to the maximum extent possible under applicable law. where applicable, i abandon its copyright to the public domain. i wrote and published this comment in argentina in 02023

Re:GNU Units by dredmorbius on Saturday August 05, 2023 @03:08AM (#37009715)
I use GNU Units a lot (and have mentioned it fairly frequently on HN -- 37 comments and one story submission: <https://news.ycombinator.com/item?id=7297219>), and have for a couple of decades now, but not like this, despite what I consider to be some reasonably advanced conversions (e.g., <https://news.ycombinator.com/item?id=8196590> & <https://news.ycombinator.com/item?id=7606949>).

This is an absolutely awesome comment. Thanks, kragen.

Re:GNU Units by kragen on Sunday August 06, 2023 @01:53PM (#37024681)
thank you, that means a lot