How to convert float to int in #define statement?

P

Peng Yu

What I really want in the second line of the following code segment is
floor(1000/s)? Is there anyway to do that?

Thanks,
Peng

#define s 1.5433
#define N 1000/s

double a[N];
 
A

Arthur J. O'Dwyer

What I really want in the second line of the following code segment is
floor(1000/s)? Is there anyway to do that?

Thanks,
Peng

#define s 1.5433
#define N 1000/s

double a[N];

double a[(int)(1000/s)];

ought to do the trick. Your subject line really says all you needed to
know: to convert any type to 'int', just convert it to 'int' (with a
cast).

-Arthur
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top