forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem of round-tripping Double values (dotnet#3101)
* Problem of round-tripping Double values * Addressed review comments, revised Single documentation * Incorporated reviewer comments
- Loading branch information
Ron Petrusha
committed
Sep 23, 2017
1 parent
e89ea10
commit a11b9ca
Showing
15 changed files
with
122 additions
and
36 deletions.
There are no files selected for viewing
56 changes: 32 additions & 24 deletions
56
docs/standard/base-types/standard-numeric-format-strings.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
samples/snippets/standard/base-types/format-strings/biginteger-r.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#using <System.Numerics.dll> | ||
|
||
using namespace System; | ||
using namespace System::Numerics; | ||
|
||
void main() | ||
{ | ||
BigInteger value = BigInteger::Pow(Int64::MaxValue, 2); | ||
Console::WriteLine(value.ToString("R")); | ||
} | ||
// The example displays the following output: | ||
// 85070591730234615847396907784232501249 | ||
|
||
|
14 changes: 14 additions & 0 deletions
14
samples/snippets/standard/base-types/format-strings/biginteger-r.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Numerics; | ||
|
||
public class Example | ||
{ | ||
public static void Main() | ||
{ | ||
var value = BigInteger.Pow(Int64.MaxValue, 2); | ||
Console.WriteLine(value.ToString("R")); | ||
} | ||
} // The example displays the following output: | ||
// 85070591730234615847396907784232501249 | ||
|
||
|
10 changes: 10 additions & 0 deletions
10
samples/snippets/standard/base-types/format-strings/biginteger-r.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Imports System.Numerics | ||
|
||
Module Example | ||
Public Sub Main() | ||
Dim value = BigInteger.Pow(Int64.MaxValue, 2) | ||
Console.WriteLine(value.ToString("R")) | ||
End Sub | ||
End Module | ||
' The example displays the following output: | ||
' 85070591730234615847396907784232501249 |
20 changes: 20 additions & 0 deletions
20
samples/snippets/standard/base-types/format-strings/csharp/g17.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
|
||
public class Example | ||
{ | ||
public static void Main() | ||
{ | ||
double original = 0.84551240822557006; | ||
var rSpecifier = original.ToString("R"); | ||
var g17Specifier = original.ToString("G17"); | ||
|
||
var rValue = Double.Parse(rSpecifier); | ||
var g17Value = Double.Parse(g17Specifier); | ||
|
||
Console.WriteLine($"{original:G17} = {rSpecifier} (R): {original.Equals(rValue)}"); | ||
Console.WriteLine($"{original:G17} = {g17Specifier} (G17): {original.Equals(g17Value)}"); | ||
} | ||
} | ||
// The example displays the following output: | ||
// 0.84551240822557006 = 0.84551240822557: False | ||
// 0.84551240822557006 = 0.84551240822557006: True |
17 changes: 17 additions & 0 deletions
17
samples/snippets/standard/base-types/format-strings/vb/g17.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Module Example | ||
Public Sub Main() | ||
Dim original As Double = 0.84551240822557006 | ||
Dim rSpecifier = original.ToString("R") | ||
Dim g17Specifier = original.ToString("G17") | ||
|
||
Dim rValue = Double.Parse(rSpecifier) | ||
Dim g17Value = Double.Parse(g17Specifier) | ||
|
||
Console.WriteLine($"{original:G17} = {rSpecifier} (R): {original.Equals(rValue)}") | ||
Console.WriteLine($"{original:G17} = {g17Specifier} (G17): {original.Equals(g17Value)}") | ||
End Sub | ||
End Module | ||
' The example displays the following output: | ||
' 0.84551240822557006 = 0.84551240822557 (R): False | ||
' 0.84551240822557006 = 0.84551240822557006 (G17): True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters