tc39 / proposal-measure

MIT License
12 stars 1 forks source link

Mixed units: index by largest or smallest unit? #11

Open sffc opened 3 weeks ago

sffc commented 3 weeks ago

In a mixed unit such as "foot-and-inch", in what unit should the scalar value be indexed?

Should 5 feet 10 inches be:

  1. 70 foot-and-inch (indexed in smallest unit)
  2. 5.833 foot-and-inch (indexed in largest unit)

ICU internally does option 2, but I don't see that behavior discussed in UTS 35.

@macchiati @younies @ben-allen

ben-allen commented 3 weeks ago

I've been assuming option 2, largely because I've been thinking of precision as being tied to the larger unit. An argument in favor of option 1 might be the meter-and-centimeter mixed unit used for person-heights in some locales; when creating a Measure using meter-and-centimeter as unit, it is likely more natural to give (for example) 180 instead of 1.80 for value.

eemeli commented 1 day ago

I think it semantically must be the largest unit. Otherwise, it would be Very Surprising if e.g. converting from foot to foot-and-inch would change the value.

ljharb commented 1 day ago

why would it be surprising that converting to another unit would change the value? isn't that the primary purpose of converting to another unit?

eemeli commented 11 hours ago

Converting from foot to foot-and-inch may make sense if you want to format the non-whole-foot part of the value with inches, rather than fractional feet. And if you're doing that, it would be surprising if you didn't still have a value in feet at the end.

sffc commented 4 hours ago

I think there are multiple mental models here, and both are valid.

One is:

"5 ft 10 in" is a nicer way of saying "70 in"

The other is:

"5 ft 10 in" is a nicer way of saying "5.833 ft"

Depending on which mental model you subscribe to, the answer to this question may differ.

(edited to make options 1 and 2 here line up with the OP)

sffc commented 4 hours ago

My personal opinion: I tend to subscribe to the first mental model: "5 ft 10 in" is a more comprehensible version of "70 in". Evidence from context person-height:

Anecdotally, I have never heard anyone refer to height as "5 point something feet" or even "five-and-a-half feet".


One other advantage of using smallest-unit indexing is that digit display options make more sense. For example, if you say minimumFractionDigits: 2, that can only refer to the smallest unit, since the larger units are always truncated to an integer.

ljharb commented 4 hours ago

To be clear, given those three options, "5.8333 feet" is the worst by a large margin.

I also agree that feet + inches is nicer than just inches, unless I'm measuring something :-)

eemeli commented 4 hours ago

Evidence from context person-height

On the other hand, consider degrees-and-arc-minutes-and-arc-seconds.