I am currently receiving this output when I run this line of code: Program received signal SIGFPE, Arithmetic exception. int number = log2 (integer value/integer value); What could be causing this? My test numbers are 128 and 134217728, i.e. log2(134217728 / 128) Source: Windows Que..

#### Category : logarithm

I have a range of base-10 logarithmically spaced points and I need to calculate the #points-per-decade for the points. Based on this section from wikipedia we have #decades = log10(start / stop). From this we should be able to calculate #points-per-decade as #points / #decades. However this does not give the right answer. Here is ..

I want to take the base of the logarithmic function as input from the user. Assuming base for example log10(100) can be calculated easily. What if the users are flexible to take the random base of the logarithmic function as input? [code-image][1] [1]: https://i.stack.imgur.com/1QoQI.png Source: Windows Que..

Question link My code bool isPowerOfThree(int n) { if(n == 0) return false; double x = log(n)/log(3); if(x == ceil(x)) return true; return false; } Why am I getting the wrong answer for n = 243? I cout the both x and ceil(x) and both are equal. Also when I do the log10 instead of ..

What’s wrong? How to calculate the logarithm in this function? How to do input validation? How do I check for negative exponents? Why does the function exist when the logarithm is negative, but the code does not recognize it? I put restrictions on the negative logarithm, but the function for negative values of the logarithm ..

I can’t search what does the logarithm code look like in C++? What the code of the logarithm function looks like in C++ in the library cmath? Exactly the code. I don’t need to figure out how I can get the logarithm. I want to know how this algorithm works. Source: Windows Que..

hello beautiful people. I was given this question to write a c++ code to calculate the range of A if and meet in 3 points. actually using geogebra classic I figured out that it’s impossible (they meet in two points or less) but our teacher insists that it’s possible and there is a solution for ..

Original problem. Find the maximum value of Hamming distance M, in decimal, in range [a, b] so that a at least 1, b at most 10^1000000. Let num_a=log10(a)+1, num_b=log10(b)+1, I see that: If num_a!=num_b, so M=num_b, i.e., M(1, 11)=M(1, 10)=2, Else, I realize that, we should start from the their first left digits, if they ..

I am trying to calculate really accurate values more than 18 decimal places. I am trying to calculate log10 (1e18 +1) by a C++ program. The value of log10 (1e18 +1) is really accurate and I don’t know of logarithm function can hold ? https://www.wolframalpha.com/input/?i=log+base+10+of+1e18+%2B+1 Here it’s my code: #include <iostream> #include <iomanip> #include <cmath> ..

Given the following code (specifically using Embarcadero C++ Builder XE3): int GetNDig(float fVal, float fTol) { int tolCoeff = floor(-1 * (logf(fTol)/logf(10))); int nDig = tolC – floor(logf(fVal)/logf(10)); if (nDig < 0) { nDig = 0; // Limit to 0 } return nDig; } void ButtonClick(…) { float val = 12.3456789; tol = 0.001; int ..

## Recent Comments