microC library for pow() function

Discussion in 'The Projects Forum' started by saman1969, Nov 4, 2012.

  1. saman1969

    Thread Starter New Member

    Nov 2, 2012
    15
    0
    mikroC should recognize its standard library "math". but I could not use it .what is the matter? do i correctly use this library? i included <math.h> in the first of my code . is it enough?
    thanks
     
  2. Tahmid

    Active Member

    Jul 2, 2008
    344
    25
    Yes, it should.
    Not required.
    Post your code and exactly explain your problem. Is there a compile error? Or does the program compile but not work as expected?
     
  3. saman1969

    Thread Starter New Member

    Nov 2, 2012
    15
    0
    my code is "#include <math.h>" and it can not compile. when i comment this statement my code will be compile coorectly.
    thanks
     
  4. Tahmid

    Active Member

    Jul 2, 2008
    344
    25
  5. saman1969

    Thread Starter New Member

    Nov 2, 2012
    15
    0
    many thanks tahmid , but by including any header file , compiler has an error in the function pow() . I typed " sr = sr && pow(2,i);" , that , sr is a variable and 'i' is the counter in a 'for' statement. both of 'sr' and 'i' are declared previously . but complier show error for using this statement.
     
  6. Papabravo

    Expert

    Feb 24, 2006
    10,138
    1,787
    && is a relational operator. Did you consider that?
     
  7. saman1969

    Thread Starter New Member

    Nov 2, 2012
    15
    0
    yes . I want to reach this result : sr <-- sr .and . (2^i). has the instruction i uesed any problem?
     
  8. n1ist

    Active Member

    Mar 8, 2009
    171
    16
    & is a boolean and. && is a logical and. Also, for powers of 2, a shift is much more efficient than a call to pow().

    sr = sr & (0x1 << i);
     
    saman1969 likes this.
Loading...