What is dot operator in C++ macro function? [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 4 days ago.
Improve this question
#define LPF(Y,X,Fb,Fs) Y=Y*exp(-PI2*Fb/Fs)+X*(1.-exp(-PI2*Fb/Fs))
#define LPF_Gamma(Y,X,Gamma) Y=Y*Gamma+X*(1.-Gamma)
#define Gamma_Cal(Gamma,Fb,Ts) Gamma=exp(-PI2*Fb*Ts)
#define LPF_Gamma(Y,X,Gamma) Y=Y*Gamma+X*(1.-Gamma)
What is dot operator in C++ macro function?
1.-Gamma
#define F(x) std::cout << 1.-x << '\n'
Result: F(10) = -9

Related

How to store an int from a string [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 2 years ago.
Improve this question
Hello I am using c++ for this assignment.
If I have a string such as "P10" and I want to store the number 10 into an integer disregarding the P, how would I do that?
Assuming you only want to remove the first character from your string then
#include <string>
std::string str = "P10";
int i = std::stoi(str.substr(1));

C++ Preprocessor semicolon [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 5 years ago.
Improve this question
I want to write code like this MAKE var=NUMBER: 21, which can be translated to
auto var=21;.
I have defined the following macros: #define MAKE auto and
#define NUMBER (1==0)? , but they did not work well.
To put it simple, I would like to add the semicolon at the end of the definition automatically.
Thanks.
It is not achievable with C++ macro syntax. You have only macro before 21 and not after. Though you can achieve that if you change your syntax slightly:
MAKE var=NUMBER(21)
instead of
MAKE var=NUMBER: 21
and define NUMBER as:
#define NUMBER(x) (x);

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;

How to write this mathematical formula in C++? [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
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/

What is the expansion of this GNU C,C++ macro [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 8 years ago.
Improve this question
What these C macros get expanded to ?
#define PERIPH_BASE ((uint32_t)0x40000000)
#define AHB2PERIPH_BASE (PERIPH_BASE + 0x08000000)
#define GPIOA_BASE (AHB2PERIPH_BASE + 0x0000)
#define GPIOB_BASE (AHB2PERIPH_BASE + 0x0400)
#define BLINK_GPIOx(_N) (GPIO_TypeDef *)(GPIO_BASE +(GPIOB_BASE-GPIOA_BASE)*(_N)))
#define BLINK_PORT_NUMBER(4)
the call to this is
GPIO_SetBits(BLINK_GPIOx(BLINK_PORT_NUMBER), BLINK_PIN_MASK(8));
Use -E option of gcc compiler to see the preprocessor output.
example: gcc -E program.c -o preprocessOutput.p
Then view the contents of the file preprocessOutput.p