Thread: double integer math problems surpass my programming skills

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by errigour
    What happen's to integers when the sum is never ending?
    For unsigned integer types, you just keep cycling through the range of numbers forever. For signed integer types, the behaviour is implementation defined. Why would you want to have a case where "the sum is never ending" anyway?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by laserlight View Post
    For unsigned integer types, you just keep cycling through the range of numbers forever. For signed integer types, the behaviour is implementation defined. Why would you want to have a case where "the sum is never ending" anyway?
    Perhaps he/she is talking about fractions and irrational numbers etc. I.e. anything where the decimal representation is infinite.

    The answer then is that a double essentially stores values in scientific notation. It has a certain number of significant figures. The result is therefore only an approximation. There's more to it than that, if you feel up to reading "What every computer scientist should know about floating point."
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  3. #18
    Registered User errigour's Avatar
    Join Date
    Mar 2009
    Posts
    102
    Hey is this valid
    Code:
    if (mouse_x >< mouse_y)

  4. #19
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by errigour
    Hey is this valid
    Did you try it? ><
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #20
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    What would that imply if it were valid? (It is not.)

    Soma

  6. #21
    Registered User errigour's Avatar
    Join Date
    Mar 2009
    Posts
    102
    mouse_x is greater then or less then mouse_y.

  7. #22
    Registered User
    Join Date
    Mar 2009
    Posts
    344
    It's spelled !=, for not-equal.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to programming - Lack math skills
    By EdMarx in forum C Programming
    Replies: 16
    Last Post: 05-23-2012, 11:38 PM
  2. Replies: 2
    Last Post: 06-07-2011, 10:05 PM
  3. help my math (int/double)
    By major_small in forum C++ Programming
    Replies: 1
    Last Post: 12-04-2003, 02:36 PM
  4. Very large signed integer math question
    By Criz in forum C Programming
    Replies: 8
    Last Post: 12-01-2002, 12:43 PM
  5. Need math skills
    By Megatron in forum C++ Programming
    Replies: 4
    Last Post: 02-21-2002, 12:04 PM