Getting Negative Int

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Smithers

    #1

    Getting Negative Int

    int k = 8;

    elsewhere in the code, I need to k to be -8.

    I could do this:

    int negativeVal = 0 - k;

    is there a better way?

    Thanks!


  • Mythran

    #2
    Re: Getting Negative Int


    "Smithers" <A@B.com> wrote in message
    news:eXKLWazWFH A.3996@TK2MSFTN GP09.phx.gbl...[color=blue]
    > int k = 8;
    >
    > elsewhere in the code, I need to k to be -8.
    >
    > I could do this:
    >
    > int negativeVal = 0 - k;
    >
    > is there a better way?
    >
    > Thanks!
    >[/color]

    Not sure, have you tried:

    int negativeVal = -k;

    HTH,
    Mythran

    Comment

    Working...