--- Renaud Deraison <deraison@private> wrote: > > On Oct 6, 2005, at 19:46, Jon Passki wrote: > > > > Yeah, if I can break it down ;-) Cyclical answer, I know. The > > string is an IP address, basically, in quad-octet form. The > moment > > any numeric routines are applied, it's converted to an int, > rounded > > to 2^31. > > No, it's converted to a signed int, so if you just perform bit- > shifting operations then things are working. > > What do you want to do exactly ? I disagree (but would be happy to eat my words). If it was converted to just a signed int, I should have a pretty big negative value, since the sign bit is set to 1, with the remaining values, two off IIRC. That is true if two defined ints less than 2^31-1 are added together, since they overflow. But the string to int conversion leaves me with exactly 2^31 - 1. 2172748161 is 129.129.129.129 in quad-octet decimal format (or 0x81818181), which is the end goal. Converting from an int to quad is easy (got the code already, just bitwise shifts by >> 8 & 255 as you mentioned already). Doing something w/ the string doesn't give the desired result: stuff = "2172748161"; display ( stuff + "\n"); poo[0] = stuff & 255; display ( poo[0] + "\n"); outputs: 2172748161 255 it should have outputed... 2172748161 129 [or whatever the negative value & w/ 255 would be, which I think is 2 off] Did I miss something? Should I be using some other type of string function? My input is an HTTP string, not a straight int. I think this is the issue because I'm converting from an ASCII string to an int. I think the conversion truncates everything down to 2^31-1. Jon __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com _______________________________________________ Plugins-writers mailing list Plugins-writers@private http://mail.nessus.org/mailman/listinfo/plugins-writers
This archive was generated by hypermail 2.1.3 : Thu Oct 06 2005 - 18:06:44 PDT