How to write this mathematical formula in C++? [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a simple formula and I want to use it in C++ application.
Not sure how to rewrite in C++.

logn(5, abs((a*b - d*c) / (tan(c) + sin(d))))
where logn is:
double logn(double base, double x) {
return log(x) / log(base);
}
and the header cmath is included for the other functions.

You can do this, be careful with libs, namespaces, and radian arguments
z = a*b - d*c;
s = tan(c) + sin(d);
num = abs(z/s);
log(num)/log(5);
http://www.cplusplus.com/reference/cmath/

Related

convert pascal to c++, i do not know about pascal [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
PBYTE(inAddr)^ := $E8;
PDWORD(inAddr + 1)^ := rMemAddr - inAddr - 5;
I need convert code to c++, but i do not know about Pascal, pls help me, thanks!
I tryed, but the two line code is wrong.
Taking a guess I would say
*(uint8_t*)inAddr = 0xE8;
*(uint32_t*)(inAddr + 1) = rMemAddr - inAddr - 5;
I do remember that ^ is the indirection operator in Pascal and := is the assignment operator.

(C++)trying to convert double to integer (explaining) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
saw this in an example
double x = 50.2
cout << (double)(int)(x);
this works fine , and also it works without the (double) ,
so why adding the (double) there?
You don't have to add (Double) there, why indeed. You are converting 50.2 to int wich evaluates to 50, then you are converting 50 back to double wich stays at 50 If you print it. The only reason i can think to do this is If it's inside some function with a return double value or to extract the integer part of a Double value, but it's not a good practice at all.

How do you transform a number to its sign? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How do you transform a number to its sign (for example -50 = -1, 50 = 1) without using the if statement, just mathematical operations?
Why not just do this
int sign = i<=0 ? -1 : 1;

C++ input value process as math function [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I’m very new in C++ and I need your help. I want to use the input value as a mathematical function then print the result.
What i need is:
When user input: 2 +1 and hit Enter then output (cout>>)
should be your result is: 3 (the sum of 2 + 1)
The mathematical symbol could be + or * or / or -.
Could you please help me with some example?
Thanks in advance!
Search for "Reverse Polish notation" and implementation in C++

How to calculate modulus? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a task to create a mathematical formula in c++, input some variables and get a result.
The problem is that I don't know how to represent and calculate the following:
sin(3 mod 180)
I`m aware that mod operator finds the remainder of a division. I can figure that out for 180 mod 3, but for 3 mod 180.
C++ and standard C library provides methods for most arithmetic operations std::sin being one of them. You can do mod using modulo operator.
I.e. std::sin(3 % 180)