Znalostná bázaCentrum skúšok
SKSlovenčina
Vybrať jazyk13

CKTIS / C#

System.Math: praktická referencia

System.Math: praktická referencia: Math poskytuje statické numerické funkcie pre vstavané číselné typy.

Verzia: .NET API; verified on .NET 10.0.14

Syntax

System.Math /* select a documented member or constructor */

Math poskytuje statické numerické funkcie pre vstavané číselné typy.

Použite ho na obmedzenie, mocniny, odmocniny a zaokrúhlenie s vedomou voľbou preťaženia.

Float a double môžu dať NaN či nekonečno a majú chyby reprezentácie; peniaze zvyčajne vyžadujú decimal.

Math.Clamp vyžaduje min najviac max a Abs najmenšej signed hodnoty môže vyvolať OverflowException.

Úplný program skutočne používa System.Math; presne očakávaný stdout je 10.

Príklady

using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;

Console.WriteLine(Math.Clamp(12, 0, 10));

Výsledok

10

Úplný program skutočne používa `System.Math`; presne očakávaný stdout je `10`.

Zdroje