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

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