CKTIS / C#
System.Math: riferimento pratico
System.Math: riferimento pratico: Math offre funzioni numeriche statiche per i tipi numerici incorporati.
Versione: .NET API; verified on .NET 10.0.14
Sintassi
System.Math /* select a documented member or constructor */Math offre funzioni numeriche statiche per i tipi numerici incorporati.
Usalo per clamp, potenze, radici e arrotondamenti scegliendo consapevolmente l’overload.
Float e double possono produrre NaN o infinito e hanno errori di rappresentazione; il denaro richiede spesso decimal.
Math.Clamp richiede min minore o uguale a max e Abs del minimo signed può generare OverflowException.
Il programma completo usa realmente System.Math; lo stdout esatto atteso è 10.
Esempi
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));
Risultato
10
Il programma completo usa realmente `System.Math`; lo stdout esatto atteso è `10`.