Home php教程 PHP源码 将输入转换为32位无符号整数,若溢出,则只保留低32位

将输入转换为32位无符号整数,若溢出,则只保留低32位

May 25, 2016 pm 05:09 PM

将输入转换为32位无符号整数,若溢出,则只保留低32位

function uint32val($var) {
    if (is_string($var)) {
        if (PHP_INT_MAX > 2147483647) {
            $var = intval($var);
        } else {
            $var = floatval($var);
        }
    }
    if (!is_int($var)) {
        $var = intval($var);
    }
    if ((0 > $var) || ($var > 4294967295)) {
        $var &= 4294967295;
        if (0 > $var) {
            $var = sprintf('%u', $var);
        }
    }
    return $var;
}
Copy after login

                   

 以上就是将输入转换为32位无符号整数,若溢出,则只保留低32位的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Disabling Win11 Input Experience Guide Disabling Win11 Input Experience Guide Dec 27, 2023 am 11:07 AM

Disabling Win11 Input Experience Guide

Windows input encounters hang or high memory usage [Fix] Windows input encounters hang or high memory usage [Fix] Feb 19, 2024 pm 10:48 PM

Windows input encounters hang or high memory usage [Fix]

Use the strconv.ParseUint function to convert a string to an unsigned integer and return an error message Use the strconv.ParseUint function to convert a string to an unsigned integer and return an error message Jul 24, 2023 pm 08:21 PM

Use the strconv.ParseUint function to convert a string to an unsigned integer and return an error message

Solve win11 search bar input problem Solve win11 search bar input problem Dec 26, 2023 pm 12:07 PM

Solve win11 search bar input problem

How to input word matrix How to input word matrix Mar 19, 2024 pm 11:00 PM

How to input word matrix

C program to input an array of sequences of integers separated by spaces C program to input an array of sequences of integers separated by spaces Aug 25, 2023 am 11:33 AM

C program to input an array of sequences of integers separated by spaces

Implementing unsigned integer recovery division algorithm in C++ Implementing unsigned integer recovery division algorithm in C++ Sep 12, 2023 pm 04:01 PM

Implementing unsigned integer recovery division algorithm in C++

PHP Practice Guide: How to determine if the input contains only numbers and letters PHP Practice Guide: How to determine if the input contains only numbers and letters Mar 28, 2024 pm 03:06 PM

PHP Practice Guide: How to determine if the input contains only numbers and letters

See all articles