Thread: C++ Pythag Calculator

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    The answer for 2 4 0 should be ~4.47, but since you (implicitly) cast that result to int, the value is truncated and 4 remains.

    In this particular case, 4 happens to be closer to the real value.

    The worrying thing is that you are using integers to store the results of calculations that result in real numbers.
    Last edited by anon; 09-19-2009 at 04:07 PM.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I need help modifying my calculator!!
    By Matus in forum C Programming
    Replies: 5
    Last Post: 03-25-2008, 12:03 PM
  2. GUI Calculator - Critique
    By The Brain in forum Windows Programming
    Replies: 1
    Last Post: 02-25-2006, 04:39 AM
  3. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  4. Need help with calculator program
    By Kate in forum C# Programming
    Replies: 1
    Last Post: 01-16-2004, 10:48 AM
  5. Replies: 2
    Last Post: 05-10-2002, 04:16 PM