Results 1 to 4 of 4

Thread: easy mathematics

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2007
    Location
    Ankara TURKEY
    Posts
    32
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8

    Question easy mathematics

    I know my problem is very easy, even for begginer but:

    Qt Code:
    1. int aa=2;
    2. int bb=3;
    3. double abd=aa^bb;
    To copy to clipboard, switch view to plain text mode 
    but i have to do it like this but i couldn't
    Qt Code:
    1. double aa=2.09;
    2. double bb=3.04;
    3. double abd=aa^bb;
    To copy to clipboard, switch view to plain text mode 
    error: invalid operands of types `double' and `double' to binary `operator^'
    What is the solition?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 268 Times in 268 Posts
    Wiki edits
    20

    Default Re: easy mathematics

    Like the error states, the ^ operator is a binary operator. It does not calculate the power.

    You can use the math lib and the pow() function.

  3. The following user says thank you to tbscope for this useful post:

    uygar (6th October 2010)

  4. #3
    Join Date
    Sep 2007
    Location
    Ankara TURKEY
    Posts
    32
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8

    Default Re: easy mathematics

    thank u, i found the way. it is like:
    Qt Code:
    1. double aa=2.09;
    2. double bb=3.04;
    3. double abd=pow(aa,bb);
    To copy to clipboard, switch view to plain text mode 

  5. #4
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android
    Thanks
    7
    Thanked 20 Times in 20 Posts

    Default Re: easy mathematics

    Remember to print the values you get: qDebug() << (aa^bb). This would have shown you immediately that your understanding of the meaning of ^ was incorrect.

Similar Threads

  1. QtScript binding wrappers? An Easy Way?
    By Statix in forum Qt Programming
    Replies: 3
    Last Post: 27th June 2010, 17:03
  2. Easy Signal-Slot-Problem
    By nearlyNERD in forum Qt Programming
    Replies: 2
    Last Post: 6th March 2010, 22:33
  3. QTextEdit... was ->text() too easy?
    By Raccoon29 in forum Newbie
    Replies: 2
    Last Post: 16th March 2008, 16:58
  4. How to retrieve lines from QTextEdit -- easy way?
    By macias in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2007, 15:44
  5. yet another easy task i cant figure out
    By sincnarf in forum Qt Programming
    Replies: 5
    Last Post: 16th October 2007, 05:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.