0

I was getting wrong values from log(), so I wrote this program just for testing:

#include <math.h>
#include <stdio.h>
void main()
{
  printf ("%1f", log(10));
}

This should print "1", but I get "2.302585"

Why is this and how can I fix it?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Luisini
  • 3
  • 1

1 Answers1

6

The log function is for the natural logarithm with base e.

It seems you want log10 instead.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621