Hi Tim

>> tup-to-num 207.69.132.8
== 3477439496

HTH
-Larry

-----------code-------------------

REBOL [
 Title: "Convert IP to number"
 Author: "Larry Palmiter"
 Date: 31-Jul-2000
 File: %tup-to-num.r
 Comment: {
Must be decimal because REBOL
does not support 32 bit unsigned.
Assumes 4 items in tuple
 }
]

tup-to-num: func [x /local out][
 out: 0.0
 x: head reverse parse to-string x "."
 repeat j 4 [
  out: out + (256.0 ** (j - 1) * to-integer x/:j)
 ]
]
  
----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 31, 2000 10:17 PM
Subject: [REBOL] converting I.P. Addresses to integer


> Hello:
> 
> How can an I.P. address be converted to an integer?
> 
> to-integer 207.69.132.8
> Is illegal as far as rebol is concerned, but
> when you really think of it:
> 207.69.132.8 really represents a 32-bit integer
> right?
> 
> So, is there any easy way to do this, or do I have
> to convert it to a string, parse it and to some
> bit-wise shifting?
> 
> TIA
> Tim

Reply via email to