1 #Module for scrappy that implements floating-point functions
2 #originally thats what it was for, now it does a bunch more things
10 scrap
.register_msg_event(float_cmd
)
11 scrap
.register_msg_event(bs_cmd
)
13 def float_cmd(c
,list,bot
):
16 cmd
= list[4].split(" ")[0]
18 if cmd
== "$" and list[4].split(" ")[1]:
21 num
= float(list[4].split(" ")[1])
24 num
= int(list[4].split(" ")[1], 16)
26 c
.privmsg(list[5],("%s: Invalid number") % list[0])
29 tmp
= struct
.pack("!f", num
)
30 tmp1
= struct
.pack("!i", num
)
31 tmp2
= struct
.pack("!d", num
)
32 tmp3
= struct
.pack("!q", num
)
34 c
.privmsg(list[5],("%s: 32bit float:0x%s | 2's complement int: 0x%s | 64bit float:0x%s | 2's complement long: 0x%s" % \
35 (list[0],binascii
.hexlify(tmp
),binascii
.hexlify(tmp1
),binascii
.hexlify(tmp2
),binascii
.hexlify(tmp3
))))
37 def bs_cmd(c
,list,bot
):
40 cmd
= list[4].split(" ")[0]
42 if cmd
== "bs" and list[4].split(" ")[1]:
45 num
= int(list[4].split(" ")[1])
48 num
= int(list[4].split(" ")[1], 16)
50 c
.privmsg(list[5],("%s: Invalid number") % list[0])
53 tmp
= struct
.pack("<i", num
)
55 c
.privmsg(list[5],("%s: 0x%s" % (list[0],binascii
.hexlify(tmp
))))