Thread: a beginner question

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    4

    a beginner question

    How do i define this formula

    X= B + (B^2 +4AC)^1/2 /2

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Didn't you just answer your own question? :d
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Hammer
    Didn't you just answer your own question? :d
    Yeah, but I wonder if they meant to use xoring.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946

    Re: a beginner question

    Originally posted by xpflyer2002
    How do i define this formula

    X= B + (B^2 +4AC)^1/2 /2
    you mean X= (-B + (B^2 +4AC)^1/2 )/ 2
    and X= (-B - (B^2 +4AC)^1/2 )/ 2
    hello, internet!

  5. #5
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    quit using the xor operator!! e.g. '^'

    what you need is the POWER function, "pow(x, y)"


    x = (-(b) + sqrt((double) (pow(b, 2) - (4*A*C)))) / (2*A)
    x = (-(b) - sqrt((double) (pow(b, 2) - (4*A*C)))) / (2*A)

    or you could use the power function and use .5 has the exp argument.



    spoooooooooon_

  6. #6
    Registered User
    Join Date
    Feb 2004
    Posts
    127
    yes ^ in C++ means XOR (Exclusive OR)

    and as spoon wrote the right way on C++ but you need to add a nother header file which is cmath.h or math.h

    ^ means power in MATLAB but not in C or C++

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >and as spoon wrote the right way on C++ but you need to add a nother header file which is cmath.h or math.h
    Or <cmath>. But believe it or not, the expression was correct for C as well. Of course, in C you would have to include <math.h>.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner: Linked List question
    By WeatherMan in forum C++ Programming
    Replies: 2
    Last Post: 04-03-2008, 07:16 AM
  2. Quick IF statement question (beginner)
    By jim.rattlehead in forum C Programming
    Replies: 23
    Last Post: 11-29-2007, 06:51 AM
  3. beginner question
    By Barrot in forum C++ Programming
    Replies: 4
    Last Post: 08-19-2005, 02:17 PM
  4. Question About External Files (Beginner)
    By jamez05 in forum C Programming
    Replies: 0
    Last Post: 08-11-2005, 07:05 AM
  5. Beginner on Win32 apps, lame question.
    By Templario in forum C Programming
    Replies: 3
    Last Post: 11-06-2002, 08:39 PM