~~ vs parseInt? [closed]

klimek

New Member
\[quote\] Possible Duplicate:
What is the “double tilde” (~~) operator in JavaScript? \[/quote\]The D3 tutorial gives a function that produces a random sequence:\[code\]var t = 1297110663, // start time (seconds since epoch) v = 70, // start value (subscribers) data = http://stackoverflow.com/questions/10841204/d3.range(33).map(next); // starting datasetfunction next() { return { time: ++t, value: v = ~~Math.max(10, Math.min(90, v + 10 * (Math.random() - .5))) };}\[/code\]Note the ~~ (tilda tilda) in:\[code\] value: v = ~~Math.max(10, Math.min(90, v + 10 * (Math.random() - .5)))\[/code\]From playing around in the javascript terminal, I see:\[code\]~~11~~-1-1~~-1.3-1parseInt(5)5parseInt(-5)-5parseInt(-5.3)-5parseInt(5.3)5\[/code\]Since ~~ and parseInt seem to be equivalent, whats the rationale for using parseInt?
 
Top