Conversation
spec/functions/number.md
Outdated
| For the purposes of formatting, | ||
| the numeric value of the _operand_ is multiplied by 100. |
There was a problem hiding this comment.
Since we have a separate function, purpose built for it, should we offer a pre-computed mode?
There was a problem hiding this comment.
You mean an option toggling if the input is multiplied or not?
There was a problem hiding this comment.
ICU4C calls it "scale" or "multiplier"
ICU4X calls it "multiply_pow10"
I don't think we've had a proper bikeshedding session on this before. I've sort-of named it what I felt like naming it and no one ever pushed back with better names.
There was a problem hiding this comment.
Given that we'll be defaulting to a value 1 getting formatted as something like "100%", I think scale makes the most sense, with a default value of 1 and supporting 100 as an alternative. With this approach,
{42 :percent scale=100}
would then be formatted as "42%".
Or is the ICU4C meaning of this option the exact opposite?
There was a problem hiding this comment.
Another thought: an enumeration might be appropriate here. Something like:
scalingMode: "scale"scales the number: 0.5 => 50%scalingMode: "passThrough"passes through the number: 50 => 50%
(sorry for the quad-post)
There was a problem hiding this comment.
In that case, scale is a rather sub-optimal choice, as it demonstrably can be understood as either "scale the number by this much" or "the scale extends to this value as the maximum".
There was a problem hiding this comment.
More suggestions, with some help from an LLM
enum PercentageScale { Fraction, Percentage }
enum InputMode { Decimal, Scaled }
enum ValueType { Normalized, Preformatted }
enum PercentMode { Ratio, Percent }
enum ScaleType { UnitInterval, WholePercent }
enum InputScale { PartsPerHundred, FinalPercent }
enum Scale { Raw, Scaled }
There was a problem hiding this comment.
Maybe style=raw, as an alternative to a default style=scaled?
There was a problem hiding this comment.
I would like to avoid any option with the unqualified style name.
spec/functions/number.md
Outdated
| The _resolved value_ of an _expression_ with a `:percent` _function_ | ||
| contains an implementation-defined numerical value | ||
| of the _operand_ of the annotated _expression_ multiplied by 100, | ||
| together with the resolved options' values. |
There was a problem hiding this comment.
For clarity, and since "resolved value" and "options" are the terms, perhaps:
| together with the resolved options' values. | |
| together with the _resolved values_ of the _options_. |
There was a problem hiding this comment.
Variants of this same snippet are used in nearly all the functions. This change would be better made separately, affecting all of them at once.
But yes, referring to the options' resolved values would be appropriate, but note that this isn't the same as options, given that the resolved options are determined by the function handler. In practice they can include ones coming from the operand as well, and don't necessarily contain all of the options.
There was a problem hiding this comment.
Perhaps "resolved values of the resolved list of options"? Oh the pedantry...
spec/functions/number.md
Outdated
| Option values with the following names are however discarded if included in the _operand_: | ||
|
|
||
| - `compactDisplay` | ||
| - `notation` | ||
| - `select` |
There was a problem hiding this comment.
Just say that all options not named in the :percent function's list above are discarded?
There was a problem hiding this comment.
That would be different from what we do with other functions, such as :integer, and it would make extensibility difficult.
An implementation could support additional options that are set in the calling code on the value being formatted, and are understood by the formatter. For a somewhat silly example, an implementation could support colour as a property of numbers, and format a "green 0.42" so that the % sign was also green in the output. If we here said that all options not explicitly listed are discarded, this kind of extensibility would not be possible.
spec/functions/number.md
Outdated
| For the purposes of formatting, | ||
| the numeric value of the _operand_ is multiplied by 100. |
There was a problem hiding this comment.
ICU4C calls it "scale" or "multiplier"
ICU4X calls it "multiply_pow10"
I don't think we've had a proper bikeshedding session on this before. I've sort-of named it what I felt like naming it and no one ever pushed back with better names.
|
During today's discussion, we noted that percent formatting is already available via This means that introducing To still support the multiplicative behaviour (which
|
I'm dubious that this is a good idea. The Note that this would mean that Also, there are other formats that we're ignoring (because they are much less common) which are supported by CLDR data, which is per-mille and per-myriad formatting. We should just solve the problem. The existence of these suggests a convenience function or maybe a convenience unit. Consider: |
|
I still have the weakly held position that :percent carries its own weight, and we should just add it and move on. It doesn't completely duplicate functionality: you use :percent if you want scaling, and :unit unit=percent if not. |
|
Another thought. If we want to try and be more general, I'd be okay with a function such as This could also be an option on But I still prefer a clean |
|
Updated as per discussion during today's meeting. |
|
This change was approved in the 2025-02-10 call. |
Fixes #956
A separate
:percentfunction is added, and thestyleoption dropped from:numberand:integer.As proposed in #987, selection is not enabled for
:percent.I've also left out the
notationandcompactDisplayoptions, as I'm not aware of any actual use cases combining them with percent formatting.