CKTIS / C#
System.Math: praktična referenca
System.Math: praktična referenca: Math ponuja statične številske funkcije za vgrajene številske tipe.
Različica: .NET API; verified on .NET 10.0.14
Sintaksa
System.Math /* select a documented member or constructor */Math ponuja statične številske funkcije za vgrajene številske tipe.
Uporabite ga za omejevanje, potence, korene in zaokroževanje z zavestno izbiro preobremenitve.
Float in double lahko dasta NaN ali neskončnost in imata napake predstavitve; denar navadno zahteva decimal.
Math.Clamp zahteva min največ max, Abs najmanjše signed vrednosti pa lahko sproži OverflowException.
Celoten program dejansko uporabi System.Math; natančno pričakovani stdout je 10.
Primeri
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));
Rezultat
10
Celoten program dejansko uporabi `System.Math`; natančno pričakovani stdout je `10`.