Thread: Using an if in a for loop

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Oh I understand now. And then it should just stay pinned at 0.

    Yeah it might work. Perhaps attempt += !!attempt
    Increment as long as it's non zero. That's kinda neat actually. Though limited in its utility.

    Quote Originally Posted by CommonTater View Post
    And FWIW .... when a signed int overflows, it does not necessarily overflow to 0... An overflow is undefined behavior, anything can happen.
    Gimme a break. Nothing will happen. Check the assembly code. I know of no machine architecture that generates an interrupt on overflow.

    You should be on a C standards committee. All academic cobbledygook and zero real-world common sense.
    Last edited by nonoob; 04-07-2011 at 10:22 AM.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by nonoob View Post
    Gimme a break. Nothing will happen. Check the assembly code. I know of no machine architecture that generates an interrupt on overflow.
    Who said anything about interrupts?

    What happens when you overflow a signed int? Does it go to 0, -1, -INT_MAX ??? I should think that's pretty much implementation specific behavior which may not be the same from one machine to the next. That is... you can't trust it.

Popular pages Recent additions subscribe to a feed