Im adding a specialised formula to a calculator, and it uses the Ln/ln function which is often on scientific calculators, how do i get this function to work in c++?
The formula is as follows:
'formula: pl * (10*diff + 10*creat +2*lines)
------------------------------------------
150 * (Ln(pl/1.5))'
Can anyone help?
Mike182
0
Light Poster
Recommended Answers
Jump to Post#include <cmath>
Use the 'log' function (which computes the natural logarithm).
Jump to PostSurely you meant
x/(150*log(pl/1.5));
I removed the multiplication sign after 'log' (which made it treated like a variable instead of a function name).
Also, as you wrote it, log(pl/1.5) would have been on the top of the fraction, so I added parentheses to put it on …
Jump to PostTry x/(150*log((double)(pl/1.5))); since log takes a double as its argument.
Jump to Postthe probleme is that you have declared log as a float. and a float is not a function and a float variable cant be used as a function.
so ether change (150*log(pl/1.5)); to (150*std::log(pl/1.5));
or remove the log float.
Jump to PostBah namespaces. Use std::log instead of log.
All 18 Replies
Rashakil Fol
978
Super Senior Demiposter
Team Colleague
Mike182
0
Light Poster
Rashakil Fol
978
Super Senior Demiposter
Team Colleague
Mike182
0
Light Poster
Rashakil Fol
978
Super Senior Demiposter
Team Colleague
Mike182
0
Light Poster
zyruz
0
Junior Poster in Training
Mike182
0
Light Poster
Rashakil Fol
978
Super Senior Demiposter
Team Colleague
Mike182
0
Light Poster
zyruz
0
Junior Poster in Training
Rashakil Fol
978
Super Senior Demiposter
Team Colleague
Mike182
0
Light Poster
Rashakil Fol
978
Super Senior Demiposter
Team Colleague
Mike182
0
Light Poster
zyruz
0
Junior Poster in Training
zyruz
0
Junior Poster in Training
Mike182
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.