mIRC Home    About    Download    Register    News    Help

Print Thread
#109245 27/01/05 01:35 AM
I
iRP
iRP
I
I think it would be great if mIRC could do << and >> conversions through its calculator or in a function. Ex: 199 >> 16

#109246 27/01/05 11:54 AM
Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Why not just multiply/divide by a power of 2? Bitshifting in such a high-level language won't offer any performance gains, if that's what you want it for.

#109247 01/02/05 03:23 AM
V
visionz
visionz
V
bitshifting with << >> is more leet wink

joking

#109248 01/02/05 04:42 AM
Joined: Mar 2004
Posts: 540
A
Fjord artisan
Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
*sigh*

#109249 01/02/05 05:19 AM
D
DaveC
DaveC
D
[just tacked onto the bottom of the thread]

alias << { if ($1 isnum) && ($2 isnum) { return $floor($calc($1 * (2 ^ ($abs($2))))) } | return $1 }
alias >> { if ($1 isnum) && ($2 isnum) { return $floor($calc($1 / (2 ^ ($abs($2))))) } | return $1 }


Just for all those who want to be leet LOL

//echo -a $$<<(129,2) $$>>(129,2)
516 32


PS: im sure it can be broken without much effort.

#109250 01/02/05 05:58 PM
Joined: Oct 2003
Posts: 3,641
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,641
how about
Code:
alias &lt;&lt; { return $base($base($$1,10,2) $+ $str(0,$$2),2,10) }
alias &gt;&gt; { return $base($left($base($$1,10,2),$+(-,$$2)),2,10) }

#109251 01/02/05 10:21 PM
D
DaveC
DaveC
D
//echo -a $>>(129,0) frown

#109252 02/02/05 04:53 AM
Joined: Oct 2003
Posts: 3,641
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,641
i didnt put that much effort into it, sorry.

#109253 06/02/05 07:04 AM
T
Tat
Tat
T
I agree. But the << and >> are pretty high language so no performance gains. Although for visualing it actually would be very helpful. Why you just multiplied by 2 when you wanted to shift every bit to the left seems odd. Anybody who doesn't grasp this feature of binary would be kinda freaked out.

I want *ALL* bitwise operations in $calc.

I tried $calc($1 & 7) once and got driven nuts.

//echo ... $calc(34 & 7)

I bugchecked for twenty minutes. I never doubted basic functions would be missing from $calc. And it worked for everything below 7. Took a while to find out you can't do a bitwise and, and how the heck you do a bitwise and.

I searched and searched, and finally came across $and()

What a joke! Add the stupid bitwise operators into calc. Not just << and >>... All of them.

^ is typically used for xor and used as power in $calc so something has to be done. Typically ** is the power function in other languages that have it natively. Because of backwards compatabilly making ^ into xor wouldn't be doable.

Nevertheless, $calc needs ALL bitwise operations!


Link Copied to Clipboard