Curiosity, learning and homework help
20/10/2021
Sign upLog in
Language: FR | ENG

> Back to the home page <

Discussion forums

[C#] Function ln(x) in C#
You have to be logged in to reply
Author Message
brainstormer

Member
Posted on 06/01/2021 at 09:24:03

by brainstormer
Member
Hi!

Do you know what is the function that I have to use in C# to calculate ln(x)?
I saw that there are Log and Log10 but there is no ln function.
TheLibrarian

**Moderator**
Posted on 06/01/2021 at 14:21:04

by TheLibrarian
**Moderator**
Hello brainstormer!

If you want to calculate ln(x) (natural logarithm) in C#, you have to use the function Log from the Math class:
Math.Log(x)

But don't forget to add the namespace System
using System;

The function Math.Log10 exists as well and allows to calculate the logarithm with base 10.
--------------------------
brainstormer

Member
Posted on 07/01/2021 at 15:57:19

by brainstormer
Member
Thank you for these precisions.
It works fine!
You have to be logged in to reply

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.