Unsigned int to signed in php

后端 未结 4 1135
别跟我提以往
别跟我提以往 2021-01-06 00:43

It appears, that in 32bit OS ip2long returns signed int, and in 64bit OS unsigned int is returned.

My application is working on 10 servers, and some are

4条回答
  •  春和景丽
    2021-01-06 01:10

    interpreting an integer value as signed int on 32 and 64 bit systems:

    function signedint32($value) {
        $i = (int)$value;
        if (PHP_INT_SIZE > 4)   // e.g. php 64bit
            if($i & 0x80000000) // is negative
                return $i - 0x100000000;
        return $i;
    } 
    

提交回复
热议问题