php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51920 ip2long result depends on platform
Submitted: 2010-05-26 12:39 UTC Modified: 2010-05-27 09:41 UTC
From: olafvdspek at gmail dot com Assigned:
Status: Not a bug Package: Network related
PHP Version: 5.3.2 OS: Debian x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: olafvdspek at gmail dot com
New email:
PHP Version: OS:

 

 [2010-05-26 12:39 UTC] olafvdspek at gmail dot com
Description:
------------
The result of ip2long depends on the plaform. It shouldn't.

Test script:
---------------
<?php
echo ip2long('192.0.34.166');

x86: -1073732954
x64: 3221234342

Expected result:
----------------
-1073732954

Actual result:
--------------
3221234342

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-26 12:42 UTC] pajoye@php.net
-Status: Open +Status: Bogus
 [2010-05-26 12:42 UTC] pajoye@php.net
See the example in the PHP manual to know how to print out unsigned integer.
 [2010-05-26 12:45 UTC] olafvdspek at gmail dot com
I know how to print an uint, that's not my question!
 [2010-05-26 13:10 UTC] pajoye@php.net
So what are you asking then? That's exactly what you are experiencing. There is no bug.
 [2010-05-26 13:11 UTC] olafvdspek at gmail dot com
I'm asking for ip2long to return the same (negative) values on all platforms.
 [2010-05-26 15:06 UTC] pajoye@php.net
So no, you don't know what an unsigned integer value is. Please ask support in one of the numerous php support channels.
 [2010-05-26 15:25 UTC] olafvdspek at gmail dot com
I know perfectly well what an unsigned int is.
 [2010-05-26 17:13 UTC] salathe@php.net
So what are you requesting? That ip2long returns a string representation of the 
number, or a float? Of which value 3221234342 or -107373295?
 [2010-05-26 17:16 UTC] olafvdspek at gmail dot com
Returning -107373295 on x64 would make it consistent with x86.

But people might prefer 3221234342, in which case it could be returned as a string.
 [2010-05-26 23:26 UTC] johannes@php.net
This would be a different binary representation, which breaks binary math, which people often do with IP addresses.
 [2010-05-26 23:28 UTC] olafvdspek at gmail dot com
Then just return the negative value.
 [2010-05-27 08:25 UTC] mike@php.net
Please read up on that topic and stop complaining about nothing.
You may start here or anywhere else:
http://en.wikipedia.org/wiki/Integer_%28computer_science%29
 [2010-05-27 09:41 UTC] olafvdspek at gmail dot com
Like I said before, I know what signed and unsigned shorts, ints, longs and long longs are.
 [2010-06-13 19:55 UTC] artificial at iol dot ie
This is why I peruse bugs.php.net... for the lulz when somebody submits a bogus bug and makes themself look stupid.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 07:01:29 2024 UTC