-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the parsing/formatting logic to allow more than 99 digits #46874
Comments
Tagging subscribers to this area: @tannergooding, @pgovind Issue DetailsAs per #46440 (comment), rather than adding new overloads API review opted to take the breaking change in how standard vs custom numeric format strings are differentiated. As per the new rules, standard numeric format strings would be identified by an ASCII alphabetical character followed by a sequence of digits. If the number of digits doesn't fit into a This is a breaking change in that today Likewise, today Format strings that start with a non ASCII alphabetical character (such as For users who want to maintain the previous behavior (that is where
|
CC. @terrajobst (also the api-review-team alias seems to be missing) |
CC. @dotnet/fxdc |
There isn't one, we use FXDC on GitHub, or maybe I don't understand what you mean. |
I have a fix locally. The only change needed was to remove the
BigInteger.ToString(string format)
BigInteger.ToString(string format, IFormatProvider provider) // This should really be the same as the previous one but just being thorough here
BigInteger.TryFormat()
// Integral Types
int/uint/byte/sbyte/short/ushort/long/ulong.ToString(string format)
int/uint/byte/sbyte/short/ushort/long/ulong.ToString(string format, IFormatProvider provider)
int/uint/byte/sbyte/short/ushort/long/ulong.TryFormat()
// Floating Types
half/single/double/decimal.ToString(string format)
half/single/double/decimal.ToString(string format, IFormatProvider provider)
half/single/double/decimal.TryFormat()
We're essentially only fixing the // Since GH formatting is rudimentary
foreach (var formatter in [DecimalFormatter, CurrencyFormatter, ExponentialFormatter, FixedFormatter, NumberFormatter, PercentFormatter, HexFormatter]) {
BigNumber:
Test ToString with precision > 99 and precision > int.MaxValue
Test TryFormat
Integral Types:
int/uint/byte/sbyte/short/ushort/long/ulong.ToString - precision > 99 and precision > int.MaxValue
Non-Integral Types:
half/single/double/decimal.ToString - precision > 99 and precision > int.MaxValue
half/single/double/decimal.TryFormat
} I also need to check that there are existing tests to cover:
|
Any idea who these partner teams might be? |
At the very least, @mjsabby from Bing. @danmosemsft might know if we have a good way to broadcast these changes internally |
I don't know of partners that are pulling directly from master at the moment (I believe Bing has paused for a little bit). My suggestion is to just use the breaking change process -- follow the issue template in the docs repo. @PriyaPurkayastha can confirm whether we need to do more. I think the Preview 1 snap happened, so we have a month or so. |
As mentioned by Dan for now, please create a breaking change issue using https:/dotnet/docs/issues/new?assignees=&labels=&template=dotnet-breaking-change.md&title= |
Ah cool, thanks! Btw, I think Preview 1 snap is Monday Jan 25? |
Ah yes I just saw the email. Thanks. |
As per #46440 (comment), rather than adding new overloads API review opted to take the breaking change in how standard vs custom numeric format strings are differentiated.
As per the new rules, standard numeric format strings would be identified by an ASCII alphabetical character followed by a sequence of ASCII digits. If the number of digits doesn't fit into a
System.Int32
, it will throw.This is a breaking change in that today
42.ToString("G999")
is interpreted as a "custom numeric format string" and will printG999
as will other values such as42.ToString("G100")
printingG142
. Moving forward, these would be interpreted as "standard numeric format strings" and would be treated as theG
format specifier with the respective number of digits, thus printing42
.Likewise, today
42.ToString("H999")
is interpreted as a "custom numeric format string" and will printH999
, while42.ToString("H99")
is interpreted as a "standard numeric format string" and sinceH
is not supported, it throws. Moving forward, both will throw sinceH
is not a supported "standard numeric format string". This leaves it open to be used in the future if necessary.Format strings, like the following, would continue to be interpreted as "custom numeric format strings":
$
orè
)A$
)A55A
).For users who want to maintain the previous behavior (that is where
42.ToString("G999")
was intentionally meant to returnG999
) they can explicitly single quote the first character (that is42.ToString("'G'999")
). This will work on .NET Framework, .NET Core, and .NET 5+The Definition of Done for this includes (but is not limited to):
The text was updated successfully, but these errors were encountered: