CKTIS / C#
System.Math: praktická reference
System.Math: praktická reference: Math poskytuje statické numerické funkce pro vestavěné číselné typy.
Verze: .NET API; verified on .NET 10.0.14
Syntaxe
System.Math /* select a documented member or constructor */Math poskytuje statické numerické funkce pro vestavěné číselné typy.
Použijte jej pro omezení, mocniny, odmocniny a zaokrouhlení s vědomou volbou přetížení.
Float a double mohou dát NaN či nekonečno a mají chyby reprezentace; peníze obvykle vyžadují decimal.
Math.Clamp vyžaduje min nejvýše max a Abs nejmenší signed hodnoty může vyvolat OverflowException.
Úplný program skutečně používá System.Math; přesně očekávaný stdout je 10.
Pří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ýsledek
10
Úplný program skutečně používá `System.Math`; přesně očekávaný stdout je `10`.