Thread: get exp of i

  1. #1
    Registered User
    Join Date
    Nov 2022
    Posts
    4

    get exp of i

    How does this method get exp


    Code:
    i += i; e = (i < 0 ? e*2+1 : e*2);
    i += i; e = (i < 0 ? e*2+1 : e*2);
    i += i; e = (i < 0 ? e*2+1 : e*2);
    i += i; e = (i < 0 ? e*2+1 : e*2);
    i += i; e = (i < 0 ? e*2+1 : e*2);
    i += i; e = (i < 0 ? e*2+1 : e*2);
    Last edited by Zooks; 11-17-2022 at 06:27 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    What are you taking about?

    "get exp of i "
    ie
    ei
    2i
    Something else?

    Where is your test code showing how you drive the code?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2022
    Posts
    4
    i is a number how does this work

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Really!?

    Where did you find this code?

    And why did you edit the number of iterations from 8 to 6?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Nov 2022
    Posts
    4
    i am trying to understand why i is added to i.

  6. #6
    Registered User
    Join Date
    Nov 2022
    Posts
    4
    i wrote a comment how it works but i deleted it i cant recall how it works anymore.

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Adding a number to itself is the same as multiplying by 2.

    I've no idea what the "i < 0" is supposed to achieve. Nothing being done to i is going to change it's sign.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Tags for this Thread