• Anon (unregistered)

    this is an inline Spinal Tap joke ...

  • Povman (unregistered) in reply to Anon

    Can someone explain the spinal tap thing please?

  • jls (unregistered) in reply to Bellinghman
    Bellinghman:
    "Hey, you know the ARM instruction set was designed by a woman in the first place?"

    Two guys designed the ARM instruction set.

    One of the two people who designed the ARM instruction set is a woman.

    Both statements are true.

    (I knew both of them by sight at the time.)


    It depends how you define 'guy', and she's very definitely female now.

  • (cs) in reply to Povman
    Anonymous:
    Can someone explain the spinal tap thing please?


    There's a scene in "This is Spinal Tap" where this guy is going on about how the gain knob on his amplifier goes up to "11" ...


  • Jasmine Strong (unregistered) in reply to Mike R
    Mike R:
    Anonymous:
    Can someone explain the spinal tap thing please?

    There's a scene in "This is Spinal Tap" where this guy is going on about how the gain knob on his amplifier goes up to "11" ...


    That's one more.

  • guest511 (unregistered) in reply to Pedant

    In assembly:

    add [i], 11

    In C etc..

    i = i+11;

  • Otto (unregistered) in reply to guest511
    i = (i << 3) + (i << 2) - i
  • (cs) in reply to Otto
    Anonymous:
    i = (i << 3) + (i << 2) - i


    er, that's i *= 11
  • Otto (unregistered) in reply to Maurits

    Well, everybody else was posting incorrect solutions, so I figured why the not me too. [;)]

    Still, if you want it to actually work:

    i = i + ((i << 3) + (i << 2) - i) / i;
     
  • (cs) in reply to macman
    Anonymous:
    WTF, of course you've got to use a loop, yes?


    I think a loop is a great solution for this!  But yours was really too simple.  Try this:

        int ThisOneGoesToEleven(int x) {
            int oldValue = x;
            int newValue = oldValue;
            int i = -11;
            do {
                oldValue = newValue;
                newValue -= Math.Sign(i++);
            } while (oldValue != newValue);
            return newValue;
        }

    Hmm.  I'm not sure if that's quite right.  Perhaps the return statement should be changed to return x + (newValue - x)?

    "The purpose of writing is to inflate weak ideas, obscure pure reasoning, and inhibit clarity. With a little pratice, writing can be an intimidating and impenetrable fog!"
                    -- Calvin (of Calvin and Hobbes)

  • andyandy (unregistered) in reply to DrCode

    Wow, a loop!? Unroll it really fast before somebody sees it! [:P]

  • CarlJoerger (unregistered) in reply to andyandy

    Why not use a table lookup?

    #define ARRAY 256

    int table[ARRAY];

    int TableFill(i)

    {

       for (int j = 0; j < ARRAY; j++) {

          table[j] = i+j;

       }

    }

    ...

       TableFill(i);

       i = table(11);

    ...

     

     

     

     

     

     

     

     

  • (cs) in reply to rick

    Anonymous:
    Um, won't i always be less than i + 11 if you keep incrementing it?

    Only until you wrap around the maximum value for i's data type. Maybe that's the point, to find out what maxint is on that system!

  • (cs) in reply to jls
    Anonymous:
    Bellinghman:
    "Hey, you know the ARM instruction set was designed by a woman in the first place?" Two guys designed the ARM instruction set. One of the two people who designed the ARM instruction set is a woman. Both statements are true. (I knew both of them by sight at the time.)

    It depends how you define 'guy', and she's very definitely female now.


    A recent 'Coding Horrors' essay about Dani Berry brought up the prevalence of transgen folk in the computer field. Unfortunately, the link to the page about TG software developers seems to be broken.

    I seem to be running into the topic a lot lately, and not just because I am a regular reader of Venus Envy, El Goonish Shive, The Wotch, and From Then on Forth, either (I hope that Erin, Dan, Anne and Liz appreciate the plug). Given my own state of mind (and gender) right now, I'm more than a bit disturbed with the way the sychronicities are piling up. I can only conclude that Lady Eris is have a bit of fun with me. All Hail Discordia...
  • dennis (unregistered) in reply to endothermal

    love the loop

    int j = 0;
    for (int i=0 ; i<11 ; i++, j++){}

  • Stingray (unregistered) in reply to Pedant

    void add(int a, int b) {
      throw a + b;
    }

    try {
      add(j, 11);
    } catch (int result) {
      j = result;
    }

  • zorro (unregistered) in reply to Stingray

    void addEleven(int i) {
        i  += 11;
    }



  • (cs) in reply to zorro

    Nah, you have to write an IncrementHandler class, with an Incrementer subclass, and in this case you would use the IncrementByEleven method.  Right?

  • Kiriai (unregistered) in reply to johnl
    <FONT face="Courier New" size=1>err32_t IncrementByEleven( int64_t *PonterToTheNumberToIncrementByEleven)</FONT>
    <FONT face="Courier New" size=1>{</FONT>
    <FONT face="Courier New" size=1>   int64_t temporaryLoopIteratorStopNumber = 0;</FONT>
    <FONT face="Courier New" size=1>   int64_t temporaryLoopIterator = 0;</FONT>
    <FONT face="Courier New" size=1>   temporaryLoopIteratorStopNumber = *PonterToTheNumberToIncrementByEleven + 11;</FONT>
    <FONT face="Courier New" size=1>   for (temporaryLoopIterator = 0; temporaryLoopIterator < temporaryLoopIteratorStopNumber; temporaryLoopIterator++)</FONT>
    <FONT face="Courier New" size=1>   {</FONT>
    <FONT face="Courier New" size=1>      *PonterToTheNumberToIncrementByEleven ++;</FONT>
    <FONT face="Courier New" size=1>   }</FONT>
    <FONT face="Courier New" size=1>   if ( *PonterToTheNumberToIncrementByEleven > 0)</FONT>
    <FONT face="Courier New" size=1>      return true;</FONT>
    <FONT face="Courier New" size=1>   else</FONT>
    <FONT face="Courier New" size=1>      return false; //The number overflowed-- return completion false error</FONT>
    <FONT face="Courier New" size=1>}</FONT>
  • (cs)

    Easy…

    for( int i = orig_var; orig_var < i + 11 ; ++orig_var );

  • AKrotkov (unregistered) in reply to poser

    lim(i + 11cos(x),x,0,1);

    Limits and trigonometrics, do I win? :D

  • o_O (unregistered)

    ,>++++++[<-------->-]+++++++++++[<+>-]<.

  • aniefer (unregistered) in reply to o_O

    Obviously its better if more of the computation can be done at compile time:

    template < int amount > int increment( int n ) {
        return increment<amount - 1>(n) + 1;
    }
    template <> int increment <0> ( int n ){
        return n;
    }

  • aniefer (unregistered) in reply to aniefer

    most of the template didnt survive the post... this is my last attempt.

    template < int amount > int increment( int n ) {
        return increment<amount - 1>(n) + 1;
    }
    template <> int increment <0> ( int n ){
        return n;
    }

  • Analy Moose (unregistered) in reply to andrew

    omg, you actually took the time to do that! :)

  • (cs) in reply to Analy Moose

    Pfft, philistines.

    (defun increment-by-11 (x)
        (funcall #'(lambda (x) (+ 11 x)) x))

  • (cs)

    >> Nathan: Okay, so how do you increment by 11?

    It's so that simple! we can design a wonderful disposition, like this:

    ++++
    + i ++
    ++++

     

    LOL

  • (cs) in reply to proteualcebidiano

    The comment one was the best...lost it in my clipboard but it was something like this.

    i+=3;  // increment by 11

     

    [:D]

  • h4XX0r (unregistered) in reply to artificialpenguin

    well,

    5 pages of comments and nobody has yet posted a solution in l33t:
    http://en.wikipedia.org/wiki/L33t_programming_language

    a11 ppl 4r3 d3f1n1t3lY n07 lE3t Th1nk0rZ!

    And this program includes a complete user interface!

  • Glebz (unregistered) in reply to h4XX0r

    create table #tbl (num int)

    declare @i int
    set @i=0
    WHILE @i <=11
    BEGIN
     INSERT #tbl VALUES (@i)
     set @i=@i+1
    end

    select top 1 * FROM #tbl
    order by num desc

    drop table #tbl

  • Anonymous Coward (unregistered) in reply to Glebz

    <font size="3">There haven't been enough solutions with randomized data...As an added bonus, I included error handling.

    Dim i As Integer
    i = InputBox("Enter Int:","I R TEH C0D3R")  
    On Error GoTo Add
    i = i / 0
    Exit Function
    Add:
    Randomize (Time)
    Dim temp As Integer
    temp = i + 11
    While i <> temp
    If i < temp Then i = i + (Rnd * 7)
    If i > temp Then i = i - (Rnd * 7)
    Wend
    </font>

  • George (unregistered) in reply to Anonymous Coward

    0 CLS
    10 numo = 0
    20 i = 0
    30 FOR i = 10 TO 0 STEP -1
    40 LET numo = numo + 1
    50 NEXT i
    60 LPRINT numo
    70 GOTO 60
    80 END

  • Rickard Norlander (unregistered)

    #define ELEVEN 12
    #define MAGICNUMBER 39

    void addNum(int * a, int b)
    {
            *a^=b;
            b=((*a^b)&b)<<1;
            if(b)
                addNum(a,b);
    }

    struct addByElevenStruct
    {
        int magicnumber;
        int multiplier;
        int number;
    };

    //Note, when you want to add 11 to MAGICNUMBER remember to use the userfriendly
    //addByEllevenStruct interface
    //Hell, just choose a good magic number like 39! Who would ever think of adding
    //11 to 39?

    void addByEleven(int * a)
    {
        int usingmagic = 0;
        int multiplier=1;
        int number=*a;
        int carry;
        if(number==MAGICNUMBER)
        {
            multiplier=((struct addByElevenStruct *)a)->multiplier;
            number=((struct addByElevenStruct )a)->number;
            usingmagic=1;
        }
        if(number==0)
        {
            if(!usingmagic)
                a=ELEVEN;
             else
                ((struct addByElevenStruct )a)->number=ELEVEN;
        }
        else
        {
            struct addByElevenStruct str;
            str.magicnumber = MAGICNUMBER;
            str.multiplier = multiplier
    2;
            carry = number%2;
            str.number = number/2;
            addByEleven((int
    )&str);
            str.number = str.number+carry
    multiplier;
            if(!usingmagic)
                *a=str.number;
            else
                ((struct addByElevenStruct *)a)->number=str.number;

        }
    }

    .
    .
    .

    addByEleven(&j);


    There is a bug left somewhere in the code as an excersie for the reader

  • Vlad Patryshev (unregistered)

    I'd suggest doubling, de-elevenation, ++-ing, then elevenation and undoubling:

    i = (++(((double)i) / 11)) * 11;

  • Moishe Lettvin (unregistered) in reply to Vlad Patryshev

    // increment 'i' by 'j'
    HRESULT Increment(int i, int j, int *pOut)
    {
        // TODO: handle the "11" case.
        if (j != 1)
        {
           return E_NOTIMPL;
        }

        i++;
        *pOut = i;
        return S_OK;
    }

  • (cs)

    Unfortunatelly, most of major programming languages are unable to implement such an operator... Anyway, mathematically, to eleven-increment is the same operation than to increment the result of a ten-increment. And so on. So let's define it (in Foo).

    (&symbol message +++ () (self ++) (self ++))
    (&symbol message ++++ () (self +++) (self ++))
    (&symbol message +++++ () (self +++) (self ++))
    ...
    (&symbol message ++++++++++++ () (self +++++++++++) (self ++))
    ; so to increment by 11 just use the operator
    ('i ++++++++++++)
  • somethingawfuldatcam (unregistered) in reply to Pedant

    <FONT style="BACKGROUND-COLOR: #ffff00" face=Verdana size=6>+11</FONT>

  • Ruby (unregistered)

    class Fixnum
      def method_missing(m)
        if n = /inc_by(_)?(\d+)/.match(m.to_s)[2].to_i
           self+n
        end
      end
    end

    puts 1.inc_by_11
    puts 2.inc_by_20
    puts 3.inc_by55

  • Anonymous (unregistered) in reply to Irrelevant
    Anonymous:

    ++++++++++i++++++++++++


    Irrelevant:
    i -= (++i - ++i) + (++i + ++i) - (++i + ++i);


    I love how people are making fun of the original coder and yet posting incorrect solutions.

    The first one will not work because you can't put i++++. In C++ terms, i++ returns a temporary integer, and you can't increment it like that. Even if you could, it wouldn't change i. ++++i works because ++i returns a reference to i.

    The second one, at least if it's C or C++, is undefined.
  • Tenacity (unregistered)

    Hey, this is actually a difficult question.

    Can someone do this using a first order logic solver? Deduce from a set of aksioms the answer to i + 11. Satisfiing this problem in a acceptable time could be tricky.

  • Bob (unregistered) in reply to Anonymous
    Anonymous:

    ...
    Irrelevant:
    i -= (++i - ++i) + (++i + ++i) - (++i + ++i);

    ...

    The second one, at least if it's C or C++, is undefined.

    The second one owns j00.
  • TH (unregistered) in reply to Bob

    while (i = i + 11) {break;}

  • Me (unregistered) in reply to Daniel

    Anonymous:
    While using increments may challenge some programmers, why does using the word "increment" challenge all programmers?  Increment is a noun, not a verb.  Code can increase a value by an increment.  Until the dictionary folks change their minds, your code can't "increment a value."  "It uses an increment of 11" makes sense.  "To increment by 11" isn't English.

     

    <FONT size=6>Verbing weirds language</FONT>

    <FONT size=2>Calvin and Hobbes</FONT>

  • Lorad (unregistered) in reply to Pedant
    <FONT color=#0000ff size=2>

    for</FONT><FONT size=2> (</FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> j = 11; j > 0; j--, i++) ;

    </FONT>
  • Jay (unregistered) in reply to bugsisus

    *one* statement, please!

    ++i,i++,++i,i++,++i,i++,++i,i++,++i,i++,++i;

  • isthisthereallife (unregistered)

    whoever didn't think of this si an idiot (java)
    int i;
    int j=i;
    while(i!=j+11)
    i=Math.random();

  • Clive Tooth (unregistered)
    Alex Papadimoulis:
    If yesterday's post was a bit too long for you, you may appreciate today's three-liner. It's from Steve Local, who had this conversation he had with one of his ... less gifted ... co-workers that was having some C# issues ...

    Nathan: Steve, you know how ++ will increment, right?
    Steve: Right ....
    Nathan: Okay, so how do you increment by 11?

    Here is a C# method, AddEleven, which may be used to increment a positive integer by 11. It uses a helper method, called Parse.

    -----------------------------


     private int AddEleven(int x)
     {
       string X;
       return
         Parse(int.Parse("0"+(X=x.ToString())[X.Length-1]))+
         int.Parse(Parse(int.Parse("0"+X.Substring(0,X.Length-1))).ToString()+"0");
     } // AddEleven

     private int Parse(int x)
     {
       string X;
       return
         int.Parse(
           char.IsNumber((char)(1+(int)(X=x.ToString())[X.Length-1]))?
           X.Substring(0,X.Length-1)+(char)(1+(int)X[X.Length-1]):
           Parse(int.Parse("0"+X.Substring(0,X.Length-1))).ToString()+"0"
         );
     } // Parse

    -----------------------------

    --

    Clive

  • J Random C Programmer (unregistered) in reply to Pedant

    i ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++;

  • Mike James (unregistered)

    #include <stdio.h>

    typedef struct eleven { char  x [11] } * evil ;

    int main ( char * argv[], int argc)
        {
        long x;
        x = 1;
        x = (long)((evil) x + 1);
        printf(" X = %ld\n",x);

        }

    produces

    X = 12


    And variants like this have appeared in mine and colleagues code. Add some preprocessor wrapping and this kind of thing gets lost...




  • John Hensley (unregistered) in reply to Anonymous
    Anonymous:

    I love how people are making fun of the original coder and yet posting incorrect solutions.

    The first one will not work because you can't put i++++. In C++ terms, i++ returns a temporary integer, and you can't increment it like that. Even if you could, it wouldn't change i. ++++i works because ++i returns a reference to i.

    The second one, at least if it's C or C++, is undefined.

    This is a humor site.

    Nobody cares about your leet C standard skillz.

    Stop it.

Leave a comment on “If ++ Increments ...”

Log In or post as a guest

Replying to comment #:

« Return to Article