PHP Chinese with 16 decimal conversion problems? 20

Updated on amusement 2024-03-30
3 answers
  1. Anonymous users2024-02-07

    PHP hexadecimal and string conversion to and from.

    function singledectohex($dec)tmp="";

    dec=$dec%16;

    if($dec<10)

    return $tmp.$dec;

    arr=array("a","b","c","d","e","f");

    return $tmp.$arr[$dec-10];

    function singlehextodec($hex)v=ord($hex);

    if(47<$v&&$v<58)

    return $v-48;

    if(96<$v&&$v<103)

    return $v-87;

    function settohexstring($str)if(!$str)return false;

    tmp="";

    for($i=0;$i";

  2. Anonymous users2024-02-06

    There are two ways to understand the conversion of hexadecimal to binary, the first is to convert hexadecimal strings to binary strings, and the second is to convert hexadecimal numbers to binary numbers

    The function can convert a hexadecimal string to a binary string, and the detailed usage is as follows:

    hex2bin — Converts hexadecimal strings into binary strings.

    string hex2bin(string $data)

    Convert hexadecimal strings to binary strings.

    Parameter: data: data in hexadecimal system.

    Return value: Returns a binary representation of the given data or false on failure.

    Exception: If the entered hexadecimal string is an odd number of long numbers or an invalid hexadecimal string will throw an e warning level error.

    Example: $hex = hex2bin("6578616d706c65206865782064617461");

    echo $hex;example hex data (where hexadecimal is ASCII code).

    It is a true base conversion function.

    base convert — convert numbers between any base.

    string base_convert( string $number, int $frombase, int $tobase)

    Returns a string containing number in tobase. The base of number itself is specified by FromBase. Both frombase and tobase can only be between 2 and 36 (inclusive).

    Numbers higher than the decimal are represented by the letters a-z, e.g. a for 10, b for 11, and z for 35.

    Parameter: number: The number to be converted.

    frombase: primitive base.

    tobase: the converted base system.

    Example: $hexadecimal ='a37334';

    echo base_convert($hexadecimal, 16, 2);//101000110111001100110100

  3. Anonymous users2024-02-05

    (php >=

    hex2bin — Converts hexadecimal strings into binary strings.

Related questions
8 answers2024-03-30

Handwriting conversion.

Divide the decimal number by 16 and keep the remainder. Once you have the remainder, don't divide it further down to get the decimals. >>>More

14 answers2024-03-30

The specific program has been sent to you via a message on the site. Test it out for yourself. >>>More

27 answers2024-03-30

Ma 3 Kong has a good-looking appearance, and the interior is not evaluated. The best of the three cars is the Ma 3, which also has the best handling. , I think it's free. >>>More

7 answers2024-03-30

Chinese name 张三, written san zhang;

Chinese name Zhang Sanfeng. >>>More

4 answers2024-03-30

Even if you don't get enough sleep.

The struggle is the most chaotic. >>>More