<<= and >>= are bit shifting operators.
<<= shifts the bits so that they are more significant, while >>= shifts them so they are less.
For example:
| #include <iostream> | |
| #include <bitset> | |
| using namespace std; | |
| int main() { | |
| cout << "* Left Bitshift: \n"; | |
| int a = 3; bitset<8> x(a); | |
| cout << "a = \t\t" << a << "\t" << x << "\n"; | |
| cout << "a <<= 2 is \t" << (a <<= 2) << "\t" << (x <<= 2) << "\n\n"; | |
| cout << "* Right Bitshift: \n"; |
| function partitionOn(pred, items) { | |
| var sp_idx = 0; | |
| for(var i in items) { | |
| if(!pred(items[i])) { | |
| // If the predicate is false, move it to sp_idx, otherwise, leave it. | |
| items.splice((sp_idx++), 0, items.splice(i, 1)[0]); | |
| } | |
| } | |
| return sp_idx; | |
| } |
| /* bowling.js - Track a bowling score | |
| * devict.org coding challenge. | |
| * To see it in action go to: | |
| * http://dev.bullercodeworks.com/bowling.html | |
| */ | |
| // To keep bowling score, we must first write a DOM manipulation framework. | |
| function B(els, attrs) { | |
| // Turn 'this' into an array of passed in elements. | |
| function B(els) { |
| #define A printf | |
| main(){int n=0,i;while(n++<100){i=0;n%3==0?A("fizz"):i++;n%5==0?A("buzz"):i++;i>1?A("%d\n",n):A("\n");}} |
| Number.prototype.formatOrdinal=function(){var n=this,s=["th","st","nd","rd"],v=n%100;return n+(s[(v-20)%10]||s[v]||s[0])}; |
| def max_subarray(A): | |
| max_ending_here = max_so_far = 0 | |
| neg_high = A[0] | |
| all_neg = True | |
| for x in A: | |
| if x > 0: | |
| all_neg = False | |
| break | |
| else: | |
| if x > neg_high: |
| public class SignatureView extends View { | |
| private static final float STROKE_WIDTH = 5f; | |
| /** Need to track this so the dirty region can accommodate the stroke. **/ | |
| private static final float HALF_STROKE_WIDTH = STROKE_WIDTH / 2; | |
| private Paint paint = new Paint(); | |
| private Path path = new Path(); |
| Number.prototype.formatPercent=function(d,sym){var n=this,d=d==undefined?0:d,sym=sym==undefined?"%":sym;return ""+(Math.round(n*(Math.pow(10,d)))/(Math.pow(10,d)))+sym;}; |
| Number.prototype.formatMoney=function(c,d,t,sym){var n=this,c=isNaN(c=Math.abs(c))?2:c,d=d==undefined?",":d,t=t==undefined?".":t,s=n<0?"-":"",i=parseInt(n=Math.abs(+n||0).toFixed(c))+"",j=(j=i.length)>3?j%3:0,sym=sym==undefined?"$":sym;return sym+s+(j?i.substr(0,j)+d:"")+i.substr(j).replace(/(\d{3})(?=\d)/g,"$1"+d)+(c?t+Math.abs(n - i).toFixed(c).slice(2):"");}; |