Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions samples/snippets/csharp/VS_Snippets_CLR/math.sign/CS/sign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static void Main()
float xSingle1 = 0.0f;
double xDouble1 = 6.0;
Decimal xDecimal1 = -7m;
nint xIntPtr1 = 8;

// The following type is not CLS-compliant.
sbyte xSbyte1 = -101;
Expand All @@ -27,6 +28,7 @@ public static void Main()
Console.WriteLine(str, "Single ", xSingle1, Test(Math.Sign(xSingle1)));
Console.WriteLine(str, "Double ", xDouble1, Test(Math.Sign(xDouble1)));
Console.WriteLine(str, "Decimal", xDecimal1, Test(Math.Sign(xDecimal1)));
Console.WriteLine(str, "IntPtr", xIntPtr1, Test(Math.Sign(xIntPtr1)));

Console.WriteLine($"{nl}The following type is not CLS-compliant.");
Console.WriteLine(str, "SByte ", xSbyte1, Test(Math.Sign(xSbyte1)));
Expand All @@ -53,6 +55,7 @@ public static string Test(int compare)
Single : 0 is equal to zero.
Double : 6 is greater than zero.
Decimal: -7 is less than zero.
IntPtr: 8 is greater than zero.

The following type is not CLS-compliant.
SByte : -101 is less than zero.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ public static void Main()
{
Console.WriteLine(
"This example of trigonometric " +
"Math.Sin( double ) and Math.Cos( double )\n" +
"Math.Sin( double ), Math.Cos( double ), and Math.SinCos( double )\n" +
"generates the following output.\n" );
Console.WriteLine(
"Convert selected values for X to radians \n" +
"and evaluate these trigonometric identities:" );
Console.WriteLine( " sin^2(X) + cos^2(X) == 1\n" +
" sin(2 * X) == 2 * sin(X) * cos(X)" );
Console.WriteLine( " cos(2 * X) == cos^2(X) - sin^2(X)" );
Console.WriteLine( " cos(2 * X) == cos^2(X) - sin^2(X)" );

UseSineCosine(15.0);
UseSineCosine(30.0);
Expand All @@ -30,6 +31,32 @@ public static void Main()

UseTwoAngles(15.0, 30.0);
UseTwoAngles(30.0, 45.0);

Console.WriteLine(
"\nWhen you have calls to sin(X) and cos(X) they \n" +
"can be replaced with a single call to sincos(x):" );

UseCombinedSineCosine(15.0);
UseCombinedSineCosine(30.0);
UseCombinedSineCosine(45.0);
}

// Evaluate trigonometric identities with a given angle.
static void UseCombinedSineCosine(double degrees)
{
double angle = Math.PI * degrees / 180.0;
(double sinAngle, double cosAngle) = Math.SinCos(angle);

// Evaluate sin^2(X) + cos^2(X) == 1.
Console.WriteLine(
"\n Math.SinCos({0} deg) == ({1:E16}, {2:E16})",
degrees, sinAngle, cosAngle);
Console.WriteLine(
"(double sin, double cos) = Math.SinCos({0} deg)",
degrees );
Console.WriteLine(
"sin^2 + cos^2 == {0:E16}",
sinAngle * sinAngle + cosAngle * cosAngle );
}

// Evaluate trigonometric identities with a given angle.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Reflection.Metadata" Version="5.0.0" />
<PackageReference Include="System.Reflection.Metadata" Version="6.0.1" />
</ItemGroup>

</Project>
59 changes: 51 additions & 8 deletions xml/System/Math.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7036,10 +7036,37 @@ The following example demonstrates how to use the <xref:System.Math.Round%28Syst
<Parameter Name="value" Type="System.IntPtr" Index="0" FrameworkAlternate="net-6.0" />
</Parameters>
<Docs>
<param name="value">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="value">A signed number.</param>
<summary>Returns an integer that indicates the sign of a native sized signed integer.</summary>
<returns>A number that indicates the sign of <paramref name="value" />, as shown in the following table.

<list type="table"><listheader><term> Return value

</term><description> Meaning

</description></listheader><item><term> -1

</term><description><paramref name="value" /> is less than zero.

</description></item><item><term> 0

</term><description><paramref name="value" /> is equal to zero.

</description></item><item><term> 1

</term><description><paramref name="value" /> is greater than zero.

</description></item></list></returns>
<remarks>
<format type="text/markdown"><![CDATA[

## Examples
The following example demonstrates how to use the <xref:System.Math.Sign%28System.IntPtr%29> method to determine the sign of an <xref:System.IntPtr> value and display it to the console.

:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/math.sign/CS/sign.cs" interactive="try-dotnet" id="Snippet1":::

]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Sign">
Expand Down Expand Up @@ -7317,10 +7344,26 @@ The following example demonstrates how to use the <xref:System.Math.Round%28Syst
<Parameter Name="x" Type="System.Double" Index="0" FrameworkAlternate="net-6.0" />
</Parameters>
<Docs>
<param name="x">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="x">An angle, measured in radians.</param>
<summary>Returns the sine and cosine of the specified angle.</summary>
<returns>The sine and cosine of <paramref name="x" />. If <paramref name="x" /> is equal to <see cref="F:System.Double.NaN" />, <see cref="F:System.Double.NegativeInfinity" />, or <see cref="F:System.Double.PositiveInfinity" />, this method returns <see cref="F:System.Double.NaN" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks
The angle, `x`, must be in radians. Multiply by <xref:System.Math.PI?displayProperty=nameWithType>/180 to convert degrees to radians.

This method calls into the underlying C runtime, and the exact result or valid input range may differ between different operating systems or architectures.



## Examples
The following example uses <xref:System.Math.SinCos%2A> to evaluate certain trigonometric identities for selected angles.

:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs" interactive="try-dotnet" id="Snippet1":::

]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Sinh">
Expand Down
17 changes: 13 additions & 4 deletions xml/System/MathF.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2097,10 +2097,19 @@ If the value of the `x` argument is <xref:System.Single.NaN?displayProperty=name
<Parameter Name="x" Type="System.Single" Index="0" FrameworkAlternate="net-6.0" />
</Parameters>
<Docs>
<param name="x">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="x">An angle, measured in radians.</param>
<summary>Returns the sine and cosine of the specified angle.</summary>
<returns>The sine and cosine of <paramref name="x" />. If <paramref name="x" /> is equal to <see cref="F:System.Single.NaN" />, <see cref="F:System.Single.NegativeInfinity" />, or <see cref="F:System.Single.PositiveInfinity" />, this method returns <see cref="F:System.Single.NaN" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks
The angle, `x`, must be in radians. Multiply by <xref:System.Math.PI?displayProperty=nameWithType>/180 to convert degrees to radians.

This method calls into the underlying C runtime, and the exact result or valid input range may differ between different operating systems or architectures.

]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Sinh">
Expand Down