All pastes #468728 Raw Edit

Red

public text v1 · immutable
·published 2007-05-03 09:48 UTC
rendered paste body
proc getIPNumber { nick host hand chan text } {
	set args $text
	set args [split $args " "]
	set IP [string toupper [lindex $args 0]]
	set IPElements [split $IP "."]
	set IP_a [lindex $IPElements 0]
	set IP_b [lindex $IPElements 1]
	set IP_c [lindex $IPElements 2]
	set IP_d [lindex $IPElements 3]
	
	set IP_initialA [expr 256*256*256]
	set IP_initialB [expr 256*256]
	
	set IP_partA [expr $IP_a * $IP_initialA]
	set IP_partB [expr $IP_b * $IP_initialB]
	set IP_partC [expr $IP_c * 256]

	set IPNumber [expr $IP_partA + $IP_partB + $IP_partC + $IP_d]

        # IP Number, X = 161 x (256*256*256) + 132 x (256*256) + 13 x (256) + 1
        # = 2709785857 <- is the correct result.
        # = -1593835520 <- result I get from the above

}