How to convert float to int in #define statement?

Discussion in 'C Programming' started by Peng Yu, Oct 19, 2004.

  1. Peng Yu

    Peng Yu Guest

    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];
    Peng Yu, Oct 19, 2004
    #1
    1. Advertising

  2. On Mon, 18 Oct 2004, Peng Yu wrote:
    >
    > 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
    Arthur J. O'Dwyer, Oct 19, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Schnoffos
    Replies:
    2
    Views:
    1,206
    Martien Verbruggen
    Jun 27, 2003
  2. bd
    Replies:
    0
    Views:
    614
  3. Nick Coghlan
    Replies:
    0
    Views:
    478
    Nick Coghlan
    Dec 6, 2004
  4. k3n3dy
    Replies:
    15
    Views:
    986
    dan2online
    Apr 20, 2006
  5. Carsten Fuchs
    Replies:
    45
    Views:
    1,525
    James Kanze
    Oct 8, 2009
Loading...

Share This Page