slightlymore

the online residence of Clinton the intertube sorcerer

  • homesee the latest blog postery
  • other sitesjust in case you're bored of this one
  • githubto take a look at my codeZ
  • contactfor if you need some company

June 7, 2009
Posted by Clinton Montague

what does the the -= operator do

The -= operator is a simplified way of writing I want to decrease the variable by a certain value. It’s called the subtraction-assignment operator.

Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$i = 10;
$i-=1;
echo $i; // outputs 9;
 
$i = 10;
$i-=5;
echo $i; // outputs 5
 
$i=10;
$i-= -10;
echo $i; // output 20 (since 10 - (-10) is the same as 10+10;
 
$i=10;
$i-=$i;
echo $i; // output 0;

Find out more

  • MSDN page about the subtraction assignment for JScript
  • Google search for “subtraction-assignment”
  • A post by me: Operator precedence – what does (i=1)*i-- - --i*(i=-3)*i++ + ++i equal and why? (not for beginners)

No Comments

Posted Under Uncategorized

No Comments Yet

You can be the first to comment!

Leave a comment

* = Required

    • Posts
    • Twitter
    • Flickr
     

    Photographing the...

    Photography

     

    Generative art...

    Uncategorized

     

    Generative art...

    Processing

    @analyseFooty if you use chrome, you can use this trick to get around it: http://t.co/U4rqW70j http://t.co/9zEPHWp3

    follow me on
    twitter

    Crescent moonGenerative art experiment 4: Spring gardenGenerative art experiment 3.5: Lord of the targetsThe MoonThe MoonGenerative art experiment 3: Lord of the ringsGenerative art experiment 2: pinkchalk spiral IGenerative art experiment 2: pinkchalk spiral IIGenerative art experiment 2: pinkchalk spiral III
  • Categories

    • 7 languages in 7 weeks
    • Emails
    • Hacking
      • Arduino
    • JavaScript
    • Lunch-time hack
    • Papervision
    • Photography
    • Programming
    • Randomness
    • Roller coasters
    • Side projects
    • Speaking
    • Uncategorized
    • Visual programming
      • Processing
  • Archives

    • 2012
      • January
      • February
    • 2011
      • January
      • February
      • March
      • April
      • June
      • November
      • December
    • 2010
      • March
      • April
    • 2009
      • January
      • February
      • March
      • April
      • May
      • June
      • July
      • August
      • September
      • October
      • December
    • 2008
      • November
      • December

This site based on the Handgloves WordPress Theme by George Wiscombe
Content © 2007-2012 Clinton Montague. Licensed under a CC Attribution-ShareAlike 3.0 Unported License Creative Commons License

Subscribe via RSS