Thread: operators operands

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    19

    operators operands

    I've been looking for hours all over the net for just a simple list of the arithmetic operators, that can be used in C, and the syntax of operators and operands, but I can't find one. Can anybody tell me where one is?

    I simply want to raise one floating point variable to a floating point power.

    Also, I noticed that if i simply try to assign to a float variable, one integer divided by another, the compiler rounds the variable's value off to an integer, but displays a bunch of zeros after a decimal point. If I divide one float variable by another, I get a (thing on the left i forgot what its called) and a mantissa. Is the program "type-casting" the variable, changing its type? I'm confused. If it was, it wouldn't display the dec point and zeros, it would seem to me.
    soil has soul

  2. #2
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382
    #include <math.h>
    .
    .
    .
    float a = 4.55;
    float b = 3.58;
    float c = pow (a, b); // a to power of b.
    Current Setup: Win 10 with Code::Blocks 17.12 (GNU GCC)

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    19
    Thanks SamGwilliam -- I was able to get my computer to exponentiate, using the information you provided in your example. I did, however, as I had before, have to say something like...

    float a;
    a = 4.55;


    to it, rather than telling it...

    float a = 4.55;

    -- because this sort of declaration caused it to respond with "Error blah blah blah."

    Perhaps this is correct syntax in another compiler, but Borland Turbo C 2.01 (circa 1989) didn't like it.
    soil has soul

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    19
    I'm still looking for a simple list of the arithmetic operators, that can be used in C, and the syntax of operators and operands. I having trouble deducing these from the math.h file.
    soil has soul

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    197
    Try this, itīs an ANSII-C-reference.

    klausi
    When I close my eyes nobody can see me...

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > I've been looking for hours all over the net for just a simple list of the arithmetic operators
    The only floating point operators which C supports "out of the box" are +,-,*,/

    Everything else (log, exponents etc) can all be found as functions in math.h

    > Perhaps this is correct syntax in another compiler, but Borland Turbo C 2.01 (circa 1989) didn't like it.
    Shouldn't be a problem - though your very OLD (and pre-ANSI) compiler should really be replaced with something more up to date

    Many excellent free compilers can be found here
    www.compilers.net

  7. #7
    Registered User
    Join Date
    Feb 2002
    Posts
    19
    Thanks klausi. Looks like one of the better references on the web (I finally managed to find a few).


    Thanks Salem. I'm thinking about buying Borland Turbo C/C++ Suite. It includes a C tutorial, not just a tutorial on using their ide.

    Since I'm just learning fundamentals, I don't need a comprehensive set of features yet. Though I like a good ide to save time.

    I downloaded djgpp already. It looks very complete. But it also has a very complex installation procedure. I have't installed it yet.
    soil has soul

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical Operators in C++
    By Flecto in forum C++ Programming
    Replies: 4
    Last Post: 05-15-2009, 07:17 AM
  2. Bolean Operators hurt my head. (Trouble understanding) :(
    By Funcoot in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2008, 07:42 PM
  3. Replies: 17
    Last Post: 02-27-2006, 12:08 PM
  4. operators???
    By arjunajay in forum C++ Programming
    Replies: 11
    Last Post: 06-25-2005, 04:37 AM
  5. Need help with C program
    By ChrisH in forum C Programming
    Replies: 38
    Last Post: 11-13-2004, 01:11 AM