!math Calculator

By Spoofing on Dec 28, 2010

:D

!math - for notice
@math - for public (channel)

<+Spoofing> @math 2pi
<+dfgsd> ~= 6.283185 ( Hex: 0x06.487ECFE9B7BF; Oct: 0006.2207731772333677; Bin: 00000110.010010000111111011 )

on *:TEXT:?math *:#: {
  if ($0 > 1) {
    var %math = $bytes($calc($replace($mid($rawmsg,$calc($pos($rawmsg,:,2) + 7)),pi,$+(*,$pi))),bd)
    if (%math) {
      var %quote = return
      if (!* iswm $1) var %quote = notice $nick
      elseif (@* iswm $1) var %quote = msg #
      %quote ~= %math ( Hex: $+(0x,$base(%math,10,16,2),;) Oct: $+($base(%math,10,8,4),;) Bin: $base(%math,10,2,8) )
    }
    else {
      msg # $+($nick,:) I don't know.
    }
  }
  else {
    msg # $+($nick,:) Use !math <expression> or @math <expression> (for public)
  }
}

Comments

Sign in to comment.
RaZ   -  Jan 07, 2011

Nice

 Respond  
Conscious   -  Dec 29, 2010

nevermind, totally misread.

 Respond  
Firstmate   -  Dec 29, 2010

Why replace pi with *pi? What if we wish to add pi?

 Respond  
sunslayer   -  Dec 29, 2010

http://es.wikipedia.org/wiki/Sistema_binarioany particular reason why you linked to a spanish page, lol?

 Respond  
jaytea   -  Dec 29, 2010

Conscious, $!chan evaluates to produce the string $chan. the exclamation mark is used, in general, to escape identifiers so they aren't interpreted as code. try this:

//echo -a $chan -- $!chan -- $!!chan -- $!identifier($me) -- $!identifier( $me )

for $! the mechanism is very simply expressed as: 'remove the first ! and then leave everything else as plain text up until the next space'.

Teen, there is a big difference between the binary representation of a real number and the binary representation of a string of ASCII text (what those 3 websites deal with). the first concept is central to understanding the binary numeral system. check out:

http://es.wikipedia.org/wiki/Sistema_binario

 Respond  
_Teen_   -  Dec 29, 2010

jaytea, i dont know if this make difference, i know the binary system, and how it works, i tried on 3 differents websites and all them showed the same result without any dot, and different from that result

http://www.easycalculation.com/ascii-hex.php

http://www.stringfunction.com/binary-hex.html

http://www.roubaixinteractive.com/PlayGround/Binary_Conversion/Binary_To_Text.asp

 Respond  
Conscious   -  Dec 29, 2010

Ah, nevermind xD

What's $!chan?

 Respond  
Jethro   -  Dec 29, 2010

lol No, Conscious. That is another story. :P

 Respond  
Conscious   -  Dec 29, 2010

What is $!chan even used for? I beleive $! refers to an input of $?="", if I am correct?

 Respond  
Jethro   -  Dec 29, 2010

No, conscious, I wasn't talking about !$chan but $!chan

I can't remember the last time I used > $!chanIf jaytea could be kind enough to show us an example involving the use of it would be greatly appreciated.

 Respond  
jaytea   -  Dec 28, 2010

Conscious, why would that make a difference? # evaluates as $chan does and produces the correct channel name. if you had said "$chan is actually documented as returning the channel associated with an event" then you would have had a point. however, # is also documented albeit not as clearly ("refers to the channel you are currently on") but thankfully the # symbol is one of the first thing newcomers to scripts encounter.

personally, i find the # more readable and noticeable in that if i'm scanning through a bunch of code, the # stands out as representing an 'output line' more so than $chan. in this particular case, i don't think there are compelling reasons to prefer one style over the other.

 Respond  
jaytea   -  Dec 28, 2010

Teen, that doesn't really make sense. binary is a numeral system, just like the decimal system with which we typically count and perform arithmetic. is 11237.81 not a valid number because we can't readily transform it into a string? the converter you mentioned clearly does not take in binary numbers; rather, it takes in a string of 8-digit binary integers.

 Respond  
Conscious   -  Dec 28, 2010

Isn't it !$chan?

Also; what if there was a channel '#'? I know in my server there is...

msg # blah would msg the channel # blah...

 Respond  
Jethro   -  Dec 28, 2010

Conscious, $chan and # are interchangeable. It's a matter of preference.

But there are situations where you need to insert an exclamation mark

$!chan

to have it evaluated properly, and that's the time we stick with $chan

Other than that, # is shorter and commonly used by many MSL coders.

 Respond  
_Teen_   -  Dec 28, 2010

is the binary right? cause i never saw a binary code, with dot
by the way, i tried on many Binary to string conversors, and only returned that

Error: Malformed binary. Your binary code is must be divisible by 8.

 Respond  
MashhitDK   -  Dec 28, 2010

Hmm... I think it looks cleaner with msg #
So I'm gonna keep using that ;)

Anyways... nice script

 Respond  
Conscious   -  Dec 28, 2010

$chan is the proper way to do it; avoid using it apart from in the top bar:
on :TEXT:?math :#: {

^ That's fine; but dont use it in the rest of the script

 Respond  
jaytea   -  Dec 28, 2010

you made the suggestion, you tell us.

 Respond  
Conscious   -  Dec 28, 2010

Why not?

 Respond  
jaytea   -  Dec 28, 2010

Spoofing, lol @ $rawmsg ))))

(what if i were using IPv6?!)

You should get into the habit of using msg $chan not msg #.

why?

 Respond  
Conscious   -  Dec 28, 2010

You should get into the habit of using msg $chan not msg #.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.