The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Fractional exponents in C? by toysbfun 2009-05-08 18:36:30
I'm trying to take the square root of 2 here, but I keep getting an "expected expression before ‘float’" error. If this is possible, what am I doing wrong?

float a, b, c;
int main(void)
{
a = 2.0;
b = (1.0/2.0);
c = float pow(float a, float b);
}


Side note: yes, I know there's sqrt(), but a) that doesn't help if I later need, say, the seventh root and b) I'm having trouble with that too.

Side question: can Java do fractional exponents? I plan on re-writing this in Java if I get OpenJDK working.
[ Reply ]
  Try it like this: by RetiQlum22009-05-08 18:43:08
    Now I have: "undefined reference to 'pow'" by toysbfun2009-05-08 18:51:10
      Changed a compiler option and it compiles by toysbfun2009-05-08 19:03:42
      My full code (Visual Studio 2005) by RetiQlum22009-05-08 19:06:35
    That code works. Thanks. (n/t) by toysbfun2009-05-08 19:05:27
      I think your problem was that you kept... by RetiQlum22009-05-08 19:08:28

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)