Curiosity, learning and homework help
28/03/2024
Sign upLog in
Language: FR | ENG

NEWSLETTER

:

MEMBERS

Come to discuss on the forum!
 FAST and FREE signup. 
😀 Access to discussion forums 😀
Help for HOMEWORKS, support in COMPUTER SCIENCE, help for learning FRENCH and ENGLISH, discussion on your INTERESTS and HOBBIES...

Following numerous requests, a new forum on PIPENET Vision has been created!

Looking for an English version of this section?

This section is in French because the contents are in French. If you prefer the English version of this section, click on the link below.
However, the contents in the French and the English sections are not necessarily the same!
Contents for mathematics in English


Quelques fonctions mathématiques en C#
En C# ("C sharp"), pour pouvoir utiliser les fonctions mathématiques, il faut d'abord importer la classe Math qui vient avec l'espace de noms System de C#. Donc il ne faut pas oublier d'ajouter l'instruction suivante :
using System;

Ensuite, toutes les fonctions de la classe Math deviennent accessibles.

    Exemple :
      using System;

      double x = Math.Cos(Math.PI);
      Console.WriteLine(x);

      Cette succession d'instructions affiche la valeur de \(cos(\pi)\), soit -1.

Voici une liste non exhaustive de fonctions disponibles dans la classe Math de C# :

  • Pour calculer le logarithme d'un nombre (logarithme naturel en base \(e\)) : \(\ln(x)\)
  • Math.Log(x)

  • Pour calculer l'exponentielle d'un nombre : \(e^x\) (ou \(\exp(x)\))
  • Math.Exp(x)

  • Pour calculer la racine carrée d'un nombre : \(\sqrt{x}\)
  • Math.Sqrt(x)

  • Pour calculer le cosinus d'un nombre : \(\cos(x)\)
  • Math.Cos(x)

  • Pour calculer le sinus d'un nombre : \(\sin(x)\)
  • Math.Sin(x)

  • Pour calculer la tangente d'un nombre : \(tan(x)\)
  • Math.Tan(x)

  • Pour utiliser le nombre pi : \(\pi\)
  • Math.PI

  • Pour calculer la puissance d'un nombre : \(x^y\)
  • Math.Pow(x,y)

  • Pour récupérer l'entier inférieur le plus proche d'un nombre (la partie entière) : le plus grand entier plus petit ou égal à x
  • Math.Floor(x)

  • Pour récupérer l'entier supérieur le plus proche d'un nombre : le plus petit entier plus grand ou égal à x
  • Math.Ceiling(x)

  • Pour calculer la valeur absolue d'un nombre : \(\lvert x \rvert\)
  • Math.Abs(x)

Si vous avez des commentaires ou des questions sur la classe Math de C#, vous pouvez venir en discuter sur le forum : Forums de discussion.
Share this page on social media:
Quick comments
• Nounou [27/02/2023 at 11:46:42]
Je suis nouveau en C# et cette liste des principales fonctions maths est vraiment utile. Merci! 🙂

Use of cookies on this website:
- If you are not a member of this website, no cookie is intentionally stored on your computer.
- If you are a member of this website, cookies are only used to keep your connection after each visit. This option can be deactivated at will in your profile and is deactivated by default.
- No other information is stored or retrieved without your knowledge, neither your personal information nor any other whatsoever. If in doubt, do not hesitate to contact the administrator of this website .
- Even this information banner does not use cookies and will therefore be displayed constantly on each visit on all pages of the website.