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 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…
GNU Units
81–90 of 117 posts
Re: GNU Units
#82Earlier quoted context omitted.
That still requires you to know about its existence. It's perfectly possible to write F# code without those and messing up units conversion.
Someone on the team needs to know about it. That person needs to set up the API to expect properly typed inputs. Others can remain ignorant about units of measurement and the compiler will educate them. F# has this built in but it can be achieved with libraries in some other languages. For example, in Haskell with the dimensional package[1]: import Numeric.Units.Dimensional.Prelude import Numeric.Units.Dimensional.No…
Go read about it yourself. NASA got some data from a contractor. The data had no units at all. The contractor assumed the data to be in some kind of US-standard units. NASA got these raw numbers and assumed they were in some kind of SI units.
Having enforced units in your language isn't going to help in this situation at all. They weren't exchanging code, they were exchanging raw data, or more specifically, a table with a bunch of numbers on it. The people at NASA simply assumed some units (instead of calling the contractor and asking), and they would have done this in your scenario too.
Re: GNU Units
#83You want: miles per hour
* 0.0074404762
/ 134.4
Re: GNU Units
#84It can convert from linear to log units, e.g.:
You have: 10W You want: dBm 40
but not the other way around (unless I'm missing something):
You have: 40 dBm ^ Parse error
I understand that log units are tricky to get right, but in some fields they are pretty ubiquitous.
Re: GNU Units
#85At some point I was looking at using a units library, but came up short because I could not find one that could convert using log scale units (which I needed). The same is True for gnu units. It can convert from linear to log units, e.g.: You have: 10W You want: dBm 40 but not the other way around (unless I'm missing something): You have: 40 dBm ^ Parse error I understand that log units are tricky to get right, but i…
You have: dBm(40)
You want: W
* 10
/ 0.1
also you can name the inverse with ~ You have: ~dBm(2 W + dBm(10))
You want:
Definition: 33.031961
the man page documents theseRe: GNU Units
#86this 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…
Thank you, these examples are amazing
Re: GNU Units
#87> You have: 17 yards + 2 feet + 5 inches Measuring things like this seems brain dead.
Yes, it's a sample, like how sample programming code snippets use names such as Foo and Bar. Similarly braindead to do it in practice! Though imperial-system users don't mix units like that, it's not like "20 minutes 30 seconds", they just use fractions or decimals as appropriate. "20 and a half minutes" or "20.5 minutes". You'd just say "17.8 yards". (Metric user here, with an appreciation for base 12)
nobody has a tape measure marked in decimal yards or decimal feet, so nobody is going to say 17.8 feet or 17.8 yards
sexagesimal system users also mix units like this: 2 hours, 10 minutes, and 5.2 seconds
same for larger units of time: 5 years, 2 months, and 12 days (which is an example units(1) can't hack)
Re: GNU Units
#88Earlier quoted context omitted.
Yes, it's a sample, like how sample programming code snippets use names such as Foo and Bar. Similarly braindead to do it in practice! Though imperial-system users don't mix units like that, it's not like "20 minutes 30 seconds", they just use fractions or decimals as appropriate. "20 and a half minutes" or "20.5 minutes". You'd just say "17.8 yards". (Metric user here, with an appreciation for base 12)
I wish our number system was duodecimal. Then we probably would have ended up with base-12 metric, which would have been freaking awesome.
You have: QuedraTim
You want: hour
* 1
/ 1
You have: QuedraTim
You want: minutes
* 60
/ 0.016666667
You have: TrinaTim
You want: minutes
* 5
/ 0.2
You have: DunaTim
You want: minutes;seconds
25 seconds
You have: QuenaTim
You want: hour
* 12
/ 0.083333333
You have: Grafut
You want:
Definition: gravity Tim^2 = 0.29558045 m
You have: QuedraGrafut
You want:
Definition: 12^4 Grafut = 6129.1562 mRe: GNU Units
#89Re: GNU Units
#90ah, so that's how you do °C / °F ... You have: tempF(45) You want: tempC 7.2222222
Temperature is weird. every other measurement scale starts at 0 but nether C nor F does. you have to use kelvin or rankine for that. This throws a big wrench into the calculation engine as now it has to support offsets for this one single use case. In fact openbsd units still does not support the C to F calculation.
?!
$ units
Currency exchange rates from FloatRates (USD base) on 2023-08-03
3539 units, 109 prefixes, 111 nonlinear units
You have: dBm(0)
You want:
Definition: 0.001 kg m^2 / s^3
You have: pH(0)You want:
Definition: 1000 mol / m^3
You have: gasmark(0)Argument of function outside domain
You have: gasmark(0.25)
You want:
Definition: 380.37222 K
You have: gasmark(0.5)You want:
Definition: 394.26111 K
You have: gasmark(0.75)You want:
Definition: 401.20556 K
You have: gasmark(1)You want:
Definition: 408.15 K
You have: gasmark(1.25)You want:
Definition: 411.62222 K
You have: shoesize_men(0)You want:
Definition: 0.20955 m
You have: shoesize_men Definition: shoesize_men(n) = shoe_men0 + n shoesize_delta
n is dimensionless
You have: bril(0)You want:
Definition: 2.5110222e-27 cd / m^2
You have: airmass Definition: airmass(alt) = 1 / (sin(alt) + 0.50572 (alt / degree + 6.07995)^-1.6364)
defined for 0 degree
You have: airmass(0 degrees)You want:
Definition: 37.919608
You have: atm_transmissionz Definition: atm_transmissionz(zenith) = exp(-extinction_coeff airmassz(zenith))
defined for 0 degree
You have: atm_transmissionz(34 degree)You want:
Definition: 0.77637004
You have: atm_transmissionz(0 degree)You want:
Definition: 0.81063327
You have: vmag(-1.46) # SiriusYou want:
Definition: 9.746164e-06 cd sr / m^2
You have: vmag(0) # VegaYou want:
Definition: 2.54e-06 cd sr / m^2
You have: baume(0)You want:
Definition: 1000 kg / m^3
You have: search gaugebrwiregauge
drillgauge
gaugepressure
plategauge
screwgauge
standardgauge 4 ft + 8.5 in
stdgauge
wiregauge
zincgauge
You have: plategauge(0)
You want:
Definition: 0.0079375 m
You have: wiregauge(0)You want:
Definition: 0.0082514628 m
You have: sugar_bp(tempF(250)) # candy boiling pointYou want:
Definition: 1475.0252 kg / m^3
You have: degF(30)You want: sugar_conc_bpe # computed via this
86.975291
You have: sugar_conc_bpe Definition: interpolated table with points
sugar_conc_bpe(0) = 0 K
sugar_conc_bpe(5) = 0.0788 K
sugar_conc_bpe(10) = 0.169 K
sugar_conc_bpe(15) = 0.2729 K
...
sugar_conc_bpe(99.6) = 70.1448 K
sugar_conc_bpe(99.7) = 76.7867 K
You have: apidegree(0) # petroleum degreeYou want:
Definition: 1076.0456 kg / m
You have: ipv4subnetsize(24)You want:
Definition: 256
You have: ipv4subnetsize(26)You want:
Definition: 64
You have: gaugepressure(0 psi)You want: psi
* 14.695949
/ 0.068045964
nonlinear and even non-affine measurement units are everywhere man