Not Yet Answered # the math Log() function misbehaves

Ancient Dragon 5,243 tesuji 135 jephthah 1,888 Ancient Dragon 5,243 Ancient Dragon 5,243 Discussion Starter SonxQ7 mitrmkar 1,056 jephthah 1,888 Discussion Starter SonxQ7 Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...

0

>> What's the problem here?

Nothing. Your program produced expected results for me. I used VC++ 2008 Express.

0

Well, then

```
cout << "natural logarithm (base e) of 7.9454E-18 is " << log(7.9454E-18)
<< "\ncommon logarithm (base 10) of 7.9454E-18 is " << log10(7.9454E-18);
//natural logarithm (base e) of 7.9454E-18 is -39.3739
//common logarithm (base 10) of 7.9454E-18 is -17.0999
```

krs,

tesu

0

when you start thinking that standard C libraries are "misbehaving", you need to take a step back and recheck your assumptions.

the most likely problems are

(1) a bug in your own code

(2) you dont understand the function like you think you do

...

(3) a distant but possible reason could be that you're using some crappy free compiler you found from some sketchy website. If you're doing that, well... stop doing that.

what you're **NOT** going to find is evidence of "misbehavior" in an ANSI C library.

0

what you're

NOTgoing to find is evidence of "misbehavior" in an ANSI C library.

Yes, I agree. Those functions have been around for quite a few years not and testest by millions of programmers all over the world. The likelyhood that anyone will find a bug is next to zero, unless you are using some newfangled compiler that has not been well tested.

0

Nothing. Your program produced expected results for me. I used VC++ 2008 Express.

That was incorrect. I actually got the same results that you did.

0

Well, then

`cout << "natural logarithm (base e) of 7.9454E-18 is " << log(7.9454E-18) << "\ncommon logarithm (base 10) of 7.9454E-18 is " << log10(7.9454E-18); //natural logarithm (base e) of 7.9454E-18 is -39.3739 //common logarithm (base 10) of 7.9454E-18 is -17.0999`

krs,

tesu

I typed this in a spreadsheet on A1

7.95E-18

formula on A2 LOG(A1) resulted in the following

-17.09988423

Excel 2003 has both LOG() & LOG10(), why would the LOG() in spreadsheet be log10() in C?

unless you are using some newfangled compiler that has not been well tested.

I use Visual Studio 2005 Standard...

0

Excel 2003 has both LOG() & LOG10(), why would the LOG() in spreadsheet be log10() in C?

Unable to answer that one, but just for reference:

Compute natural logarithm / log()

http://www.cplusplus.com/reference/clibrary/cmath/log.html

Compute base-10 logarithm / log10()

http://www.cplusplus.com/reference/clibrary/cmath/log10.html

1

Excel 2003 has both LOG() & LOG10(), why would the LOG() in spreadsheet be log10() in C?

because EXCEL is written mainly for people who don't really understand undergraduate-level mathematics, whereas C is designed for all sorts of folks, including engineers, scientists and mathematicians.

the natural logarithm, sometimes written as "ln", is the logarithm to the base *e*... all other logarithm bases are arbitrary, whether it's base 2, or base 10, or base 27.3 ... just because you have 10 fingers and think base 10 should always be implied, doesn't mean that's the case for the natural sciences, engineering, or even finance.

so C is universal in its application of logarithmic bases.

log(x) is the natural log of x.

log10(x) is the base 10 log of x

log2(x) is the base 2 log of x

if you want to use any other base, fine: use the simple property of logarithms to change the base to any arbitrary value *b*

log* b*(x) = log(x) / log(

.

0

because EXCEL is written mainly for people who don't really understand undergraduate-level mathematics, whereas C is designed for all sorts of folks, including engineers, scientists and mathematicians.

the natural logarithm, sometimes written as "ln", is the logarithm to the base

e... all other logarithm bases are arbitrary, whether it's base 2, or base 10, or base 27.3 ... just because you have 10 fingers and think base 10 should always be implied, doesn't mean that's the case for the natural sciences, engineering, or even finance.so C is universal in its application of logarithmic bases.

log(x) is the natural log of x.

log10(x) is the base 10 log of x

log2(x) is the base 2 log of xif you want to use any other base, fine: use the simple property of logarithms to change the base to any arbitrary value

blog

(x) = log(x) / log(b)b

.

thnx 4 yo info...

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.

btn_addline :

`Private Sub btn_addline_Click(ByVal ...`

I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:

```
try
{
Runtime run = Runtime.getRuntime();
Process pr = ...
```