File tree 1 file changed +13
-11
lines changed
1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -221,20 +221,22 @@ public static string Format(this DateTimeOffset value)
221
221
222
222
public static string Format ( this double value )
223
223
{
224
- // since .NET Core 3.0, the Floating-Point Formatter returns the shortest roundtrippable string, rather than the exact string
225
- // e.g. on .NET Framework (Windows)
226
- // * 2.2.ToString() -> 2.2000000000000002
227
- // * 4.4.ToString() -> 4.4000000000000004
228
- // see https://devblogs.microsoft.com/dotnet/floating-point-parsing-and-formatting-improvements-in-net-core-3-0/
229
-
230
- if ( ! IsWindows )
224
+ #if NETFRAMEWORK
225
+ if ( IsWindows )
231
226
{
232
- return value . ToString ( NumberFormatInfo . InvariantInfo ) ;
227
+ // since .NET Core 3.0, the Floating-Point Formatter returns the shortest roundtrippable string, rather than the exact string
228
+ // e.g. on .NET Framework (Windows)
229
+ // * 2.2.ToString() -> 2.2000000000000002
230
+ // * 4.4.ToString() -> 4.4000000000000004
231
+ // see https://devblogs.microsoft.com/dotnet/floating-point-parsing-and-formatting-improvements-in-net-core-3-0/
232
+
233
+ var utf16Text = value . ToString ( "G17" , NumberFormatInfo . InvariantInfo ) ;
234
+ var utf8Bytes = Encoding . UTF8 . GetBytes ( utf16Text ) ;
235
+ return Encoding . UTF8 . GetString ( utf8Bytes ) ;
233
236
}
237
+ #endif
234
238
235
- var utf16Text = value . ToString ( "G17" , NumberFormatInfo . InvariantInfo ) ;
236
- var utf8Bytes = Encoding . UTF8 . GetBytes ( utf16Text ) ;
237
- return Encoding . UTF8 . GetString ( utf8Bytes ) ;
239
+ return value . ToString ( NumberFormatInfo . InvariantInfo ) ;
238
240
}
239
241
}
240
242
You can’t perform that action at this time.
0 commit comments