<?php
$temp = 3750403596/16;
echo $temp."<br>";
$leftt = 3750403596;
$temp = $leftt/16;
echo $temp;
?>
输出:
234400224.75
234400224.75

解决方案 »

  1.   

    $leftt = 3750403596;
    $work  = (($leftt << 28) | ($leftt >> 4)); 在C中的结果是: (正确)
    printf("work=%lu,28=%lu,4=%lu\n",work,leftt<<28,leftt>>4);
    work=3455625696,28=3221225472,4=234400224在PHP中的结果是:
    printf("work=%lu,28=%lu,4=%lu\n",$work,$leftt<<28,$leftt>>4);
    work=3455625696,28=3221225472,4=4260932065就是leftt>>4的结果出错了.
      

  2.   

    What is your php version?
    With PHP 5.1.4 on my computer, all the results are "234400224.75".
      

  3.   

    My php version is 5.1.2
      

  4.   

    C:
    printf("[%d]: %lu,%lu,%lu,%lu\n", round, fval, work, right, leftt);
    work  = (leftt << 28) | (leftt >> 4);
    printf("work=%lu, 28=%lu, 4=%lu\n", work, leftt << 28, leftt >> 4);Result:
    [0]: 3732172454,1037509577,33489100,3750403596
    work=3455625696, 82=3221225472, 4=234400224这个代码的结果是正确的, 取自DES for C源代码,  现在转成PHP就有问题.
    PHP:
    printf("[%d]: %lu,%lu,%lu,%lu\n", $round, $fval, $work, $right, $leftt);
    $work  = ($leftt << 28) | ($leftt >> 4);
    printf("work=%lu, 28=%lu, 4=%lu\n", $work, $leftt << 28,  $leftt >> 4); Result:
    [0]: 3732172454,1037509577,33489100,3750403596
    work=4260932064, 28=3221225472, 4=4260932064
      

  5.   

    我测试了,也没有问题,
    php5.0.24234400224.75
    234400224.75 
      

  6.   

    感觉像是类型的问题.  PHP手册上说PHP只支持Int和Float,  如果Int超过范围, 就自动返回float, 
    $leftt的值为3750403596
    var_dump($leftt)的结果是: int(-544563700)
    说明$leftt已经起过int的范围了, 如果进行>>4, 结果为234400224, 在Int范围之内. 结果就错了.还做过一个实验, 
    printf("test: %lu\n", 3750403596 / 16);
    结果为: test: 234400224printf("test: %lu\n", ((float)(int)3750403596) / 16);
    结果为: test: 4260932065小弟一起用VC. 所以对PHP第一次亲密接触, 很多事情都不清楚, 希望在家指点一下.
      

  7.   

    <?PHP
    //PHP  version
    // Sage Baal 2007
    //
    define("EN0", 0);
    define("DE1", 1);
    $KnL = array(0=>32);
    $KnR = array(0=>32);
    $Kn3 = array(0=>32);
    $Df_Key = array(0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67);
    $bytebit = array(0200,0100,040,020,010,04,02,01);
    $bigbyte = array(0x800000,0x400000,0x200000,0x100000,
     0x80000,0x40000,0x20000,0x10000,
     0x8000,0x4000,0x2000,0x1000,
     0x800,0x400,0x200,0x100,
     0x80,0x40,0x20,0x10,
     0x8,0x4,0x2,0x1);
     
    /* Use the key schedule specified in the Standard (ANSI X3.92-1981). */
    $pc1 = array(56, 48, 40, 32, 24, 16,  8, 0, 57, 49, 41, 33, 25, 17,
      9,  1, 58, 50, 42, 34, 26,18, 10,  2, 59, 51, 43, 35,
     62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21,
     13,  5, 60, 52, 44, 36, 28,20, 12,  4, 27, 19, 11,  3);$totrot = array(1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28);$pc2 = array(13, 16, 10, 23,  0,  4,  2, 27, 14,  5, 20,  9,
       22, 18, 11,  3, 25,  7, 15,  6, 26, 19, 12,  1,
     40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
     43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31);
     $SP1 = array(
    0x01010400, 0x00000000, 0x00010000, 0x01010404,
    0x01010004, 0x00010404, 0x00000004, 0x00010000,
    0x00000400, 0x01010400, 0x01010404, 0x00000400,
    0x01000404, 0x01010004, 0x01000000, 0x00000004,
    0x00000404, 0x01000400, 0x01000400, 0x00010400,
    0x00010400, 0x01010000, 0x01010000, 0x01000404,
    0x00010004, 0x01000004, 0x01000004, 0x00010004,
    0x00000000, 0x00000404, 0x00010404, 0x01000000,
    0x00010000, 0x01010404, 0x00000004, 0x01010000,
    0x01010400, 0x01000000, 0x01000000, 0x00000400,
    0x01010004, 0x00010000, 0x00010400, 0x01000004,
    0x00000400, 0x00000004, 0x01000404, 0x00010404,
    0x01010404, 0x00010004, 0x01010000, 0x01000404,
    0x01000004, 0x00000404, 0x00010404, 0x01010400,
    0x00000404, 0x01000400, 0x01000400, 0x00000000,
    0x00010004, 0x00010400, 0x00000000, 0x01010004 );$SP2 = array(
    0x80108020, 0x80008000, 0x00008000, 0x00108020,
    0x00100000, 0x00000020, 0x80100020, 0x80008020,
    0x80000020, 0x80108020, 0x80108000, 0x80000000,
    0x80008000, 0x00100000, 0x00000020, 0x80100020,
    0x00108000, 0x00100020, 0x80008020, 0x00000000,
    0x80000000, 0x00008000, 0x00108020, 0x80100000,
    0x00100020, 0x80000020, 0x00000000, 0x00108000,
    0x00008020, 0x80108000, 0x80100000, 0x00008020,
    0x00000000, 0x00108020, 0x80100020, 0x00100000,
    0x80008020, 0x80100000, 0x80108000, 0x00008000,
    0x80100000, 0x80008000, 0x00000020, 0x80108020,
    0x00108020, 0x00000020, 0x00008000, 0x80000000,
    0x00008020, 0x80108000, 0x00100000, 0x80000020,
    0x00100020, 0x80008020, 0x80000020, 0x00100020,
    0x00108000, 0x00000000, 0x80008000, 0x00008020,
    0x80000000, 0x80100020, 0x80108020, 0x00108000 );$SP3 = array(
    0x00000208, 0x08020200, 0x00000000, 0x08020008,
    0x08000200, 0x00000000, 0x00020208, 0x08000200,
    0x00020008, 0x08000008, 0x08000008, 0x00020000,
    0x08020208, 0x00020008, 0x08020000, 0x00000208,
    0x08000000, 0x00000008, 0x08020200, 0x00000200,
    0x00020200, 0x08020000, 0x08020008, 0x00020208,
    0x08000208, 0x00020200, 0x00020000, 0x08000208,
    0x00000008, 0x08020208, 0x00000200, 0x08000000,
    0x08020200, 0x08000000, 0x00020008, 0x00000208,
    0x00020000, 0x08020200, 0x08000200, 0x00000000,
    0x00000200, 0x00020008, 0x08020208, 0x08000200,
    0x08000008, 0x00000200, 0x00000000, 0x08020008,
    0x08000208, 0x00020000, 0x08000000, 0x08020208,
    0x00000008, 0x00020208, 0x00020200, 0x08000008,
    0x08020000, 0x08000208, 0x00000208, 0x08020000,
    0x00020208, 0x00000008, 0x08020008, 0x00020200 );$SP4 = array(
    0x00802001, 0x00002081, 0x00002081, 0x00000080,
    0x00802080, 0x00800081, 0x00800001, 0x00002001,
    0x00000000, 0x00802000, 0x00802000, 0x00802081,
    0x00000081, 0x00000000, 0x00800080, 0x00800001,
    0x00000001, 0x00002000, 0x00800000, 0x00802001,
    0x00000080, 0x00800000, 0x00002001, 0x00002080,
    0x00800081, 0x00000001, 0x00002080, 0x00800080,
    0x00002000, 0x00802080, 0x00802081, 0x00000081,
    0x00800080, 0x00800001, 0x00802000, 0x00802081,
    0x00000081, 0x00000000, 0x00000000, 0x00802000,
    0x00002080, 0x00800080, 0x00800081, 0x00000001,
    0x00802001, 0x00002081, 0x00002081, 0x00000080,
    0x00802081, 0x00000081, 0x00000001, 0x00002000,
    0x00800001, 0x00002001, 0x00802080, 0x00800081,
    0x00002001, 0x00002080, 0x00800000, 0x00802001,
    0x00000080, 0x00800000, 0x00002000, 0x00802080 );$SP5 = array(
    0x00000100, 0x02080100, 0x02080000, 0x42000100,
    0x00080000, 0x00000100, 0x40000000, 0x02080000,
    0x40080100, 0x00080000, 0x02000100, 0x40080100,
    0x42000100, 0x42080000, 0x00080100, 0x40000000,
    0x02000000, 0x40080000, 0x40080000, 0x00000000,
    0x40000100, 0x42080100, 0x42080100, 0x02000100,
    0x42080000, 0x40000100, 0x00000000, 0x42000000,
    0x02080100, 0x02000000, 0x42000000, 0x00080100,
    0x00080000, 0x42000100, 0x00000100, 0x02000000,
    0x40000000, 0x02080000, 0x42000100, 0x40080100,
    0x02000100, 0x40000000, 0x42080000, 0x02080100,
    0x40080100, 0x00000100, 0x02000000, 0x42080000,
    0x42080100, 0x00080100, 0x42000000, 0x42080100,
    0x02080000, 0x00000000, 0x40080000, 0x42000000,
    0x00080100, 0x02000100, 0x40000100, 0x00080000,
    0x00000000, 0x40080000, 0x02080100, 0x40000100 );$SP6 = array(
    0x20000010, 0x20400000, 0x00004000, 0x20404010,
    0x20400000, 0x00000010, 0x20404010, 0x00400000,
    0x20004000, 0x00404010, 0x00400000, 0x20000010,
    0x00400010, 0x20004000, 0x20000000, 0x00004010,
    0x00000000, 0x00400010, 0x20004010, 0x00004000,
    0x00404000, 0x20004010, 0x00000010, 0x20400010,
    0x20400010, 0x00000000, 0x00404010, 0x20404000,
    0x00004010, 0x00404000, 0x20404000, 0x20000000,
    0x20004000, 0x00000010, 0x20400010, 0x00404000,
    0x20404010, 0x00400000, 0x00004010, 0x20000010,
    0x00400000, 0x20004000, 0x20000000, 0x00004010,
    0x20000010, 0x20404010, 0x00404000, 0x20400000,
    0x00404010, 0x20404000, 0x00000000, 0x20400010,
    0x00000010, 0x00004000, 0x20400000, 0x00404010,
    0x00004000, 0x00400010, 0x20004010, 0x00000000,
    0x20404000, 0x20000000, 0x00400010, 0x20004010 );$SP7 = array(
    0x00200000, 0x04200002, 0x04000802, 0x00000000,
    0x00000800, 0x04000802, 0x00200802, 0x04200800,
    0x04200802, 0x00200000, 0x00000000, 0x04000002,
    0x00000002, 0x04000000, 0x04200002, 0x00000802,
    0x04000800, 0x00200802, 0x00200002, 0x04000800,
    0x04000002, 0x04200000, 0x04200800, 0x00200002,
    0x04200000, 0x00000800, 0x00000802, 0x04200802,
    0x00200800, 0x00000002, 0x04000000, 0x00200800,
    0x04000000, 0x00200800, 0x00200000, 0x04000802,
    0x04000802, 0x04200002, 0x04200002, 0x00000002,
    0x00200002, 0x04000000, 0x04000800, 0x00200000,
    0x04200800, 0x00000802, 0x00200802, 0x04200800,
    0x00000802, 0x04000002, 0x04200802, 0x04200000,
    0x00200800, 0x00000000, 0x00000002, 0x04200802,
    0x00000000, 0x00200802, 0x04200000, 0x00000800,
    0x04000002, 0x04000800, 0x00000800, 0x00200002 );$SP8 = array(
    0x10001040, 0x00001000, 0x00040000, 0x10041040,
    0x10000000, 0x10001040, 0x00000040, 0x10000000,
    0x00040040, 0x10040000, 0x10041040, 0x00041000,
    0x10041000, 0x00041040, 0x00001000, 0x00000040,
    0x10040000, 0x10000040, 0x10001000, 0x00001040,
    0x00041000, 0x00040040, 0x10040040, 0x10041000,
    0x00001040, 0x00000000, 0x00000000, 0x10040040,
    0x10000040, 0x10001000, 0x00041040, 0x00040000,
    0x00041040, 0x00040000, 0x10041000, 0x00001000,
    0x00000040, 0x10040040, 0x00001000, 0x00041040,
    0x10001000, 0x00000040, 0x10000040, 0x10040000,
    0x10040040, 0x10000000, 0x00040000, 0x10001040,
    0x00000000, 0x10041040, 0x00040040, 0x10000040,
    0x10040000, 0x10001000, 0x10001040, 0x00000000,
    0x10041040, 0x00041000, 0x00041000, 0x00001040,
    0x00001040, 0x00040040, 0x10000000, 0x10041000 );
      

  8.   

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // New DES Code by sage_baal
    //function cpkey(&$into)
    {
    global $KnL;
    for( $i = 0; $i < 32; $i++ ) {
    $into[$i] = $KnL[$i];
    }
    }function usekey($from)
    {
    global $KnL;
    for( $i = 0; $i < 32; $i++ ) {
    $KnL[$i] = $from[$i];
    }
    }function cookey($raw1)
    {
    global $KnL; $dough = array(0=>32);
    $j = 0;
    $k = 0;
    $raw0 = 0;
    for( $i = 0; $i < 16; $i++, $j++ ) {
    $raw0 = $raw1[$j++];
    $dough[$k] = ($raw0 & 0x00fc0000) << 6;
    $dough[$k] |= ($raw0 & 0x00000fc0) << 10;
    $dough[$k] |= ($raw1[$j] & 0x00fc0000) >> 10;
    $dough[$k++] |= ($raw1[$j] & 0x00000fc0) >> 6;
    $dough[$k]  = ($raw0 & 0x0003f000) << 12;
    $dough[$k] |= ($raw0 & 0x0000003f) << 16;
    $dough[$k] |= ($raw1[$j] & 0x0003f000) >> 4;
    $dough[$k++] |= ($raw1[$j] & 0x0000003f);
    }
    usekey($dough);
    }

    function deskey($key,$edf) /* Thanks to James Gillogly & Phil Karn! */
    {
    global $pc1,$bytebit,$totrot,$bigbyte,$pc1,$pc2;
    $i = 0;
    $j = 0;
    $l = 0;
    $m = 0;
    $n = 0; 

    $pc1m = array(0=>56);
    $pcr  = array(0=>56);
    $kn   = array(0=>32); for ( $j = 0; $j < 56; $j++ ) {
    $l = $pc1[$j];
    $m = $l & 07;
    $pc1m[$j] = ($key[$l >> 3] & $bytebit[$m]) ? 1 : 0;
    }

    for( $i = 0; $i < 16; $i++ ) {
    if( $edf == DE1 ) $m = (15 - $i) << 1;
    else $m = $i << 1;
    $n = $m + 1;
    $kn[$m] = $kn[$n] = 0;
    for( $j = 0; $j < 28; $j++ ) {
    $l = $j + $totrot[$i];
    if( $l < 28 ) $pcr[$j] = $pc1m[$l];
    else $pcr[$j] = $pc1m[$l - 28];
    }
    for( $j = 28; $j < 56; $j++ ) {
        $l = $j + $totrot[$i];
        if( $l < 56 ) $pcr[$j] = $pc1m[$l];
        else $pcr[$j] = $pc1m[$l - 28];
        }
    for( $j = 0; $j < 24; $j++ ) {
    if( $pcr[$pc2[$j]] ) $kn[$m] |= $bigbyte[$j];
    if( $pcr[$pc2[$j+24]] ) $kn[$n] |= $bigbyte[$j];
    }
    }
    cookey($kn);
    }
    function desfunc(&$block, $keys)
    {
    global $SP1,$SP2,$SP3,$SP4,$SP5,$SP6,$SP7,$SP8; $fval = 0;
    $work = 0;
    $right = 0;
    $leftt = 0;
    $round = 0;

    settype($leftt, "float"); $leftt = $block[0];
    $right = $block[1];
    $work = (($leftt >> 4) ^ $right) & 0x0f0f0f0f;
    $right ^= $work;
    $leftt ^= ($work << 4);
    $work = (($leftt >> 16) ^ $right) & 0x0000ffff;
    $right ^= $work;
    $leftt ^= ($work << 16);
    $work = (($right >> 2) ^ $leftt) & 0x33333333;
    $leftt ^= $work;
    $right ^= ($work << 2);
    $work = (($right >> 8) ^ $leftt) & 0x00ff00ff;
    $leftt ^= $work;
    $right ^= ($work << 8);
    $right = (($right << 1) | (($right >> 31) & 1)) & 0xffffffff;
    $work = ($leftt ^ $right) & 0xaaaaaaaa;
    $leftt ^= $work;
    $right ^= $work;
    $leftt = (($leftt << 1) | (($leftt >> 31) & 1)) & 0xffffffff; $i = 0; for( $round = 0; $round < 8; $round++ ) {
    $work  = ($right << 28) | ($right >> 4);

    // printf("work=%lu\n", $work);

    $work ^= $keys[$i++];

    // printf("work=%lu\n", $work);

    $fval  = $SP7[ $work     & 0x3f];
    $fval |= $SP5[($work >>  8) & 0x3f];
    $fval |= $SP3[($work >> 16) & 0x3f];
    $fval |= $SP1[($work >> 24) & 0x3f];

    // printf("fval=%lu\n", $fval);

    $work  = $right ^ $keys[$i++];
    // printf("work=%lu\n", $work);

    $fval |= $SP8[ $work & 0x3f];
    $fval |= $SP6[($work >>  8) & 0x3f];
    $fval |= $SP4[($work >> 16) & 0x3f];
    $fval |= $SP2[($work >> 24) & 0x3f];

    $leftt ^= $fval;

    printf("[%d]: %lu,%lu,%lu,%lu\n", $round, $fval, $work, $right, $leftt);

    $work  = ($leftt << 28) | ($leftt >> 4);

    printf("work=%lu, 28=%lu, 4=%lu\n", $work, $leftt << 28,  $leftt >> 4);

    printf("test1: %lu\n", (3750403596) / 16);
    printf("test2: %lu\n", ((float)(int)3750403596) / 16);

    // printf("temp=%lu\n", $temp);// $large_number =  2147483648;
    // printf("%lu\n", $large_number - $leftt);



    // $temp = 3750403596 / 16;

    // 4294967295 // var_dump($leftt);

    $work ^= $keys[$i++];

    // printf("work=%lu\n", $work);

    $fval  = $SP7[ $work & 0x3f];
    $fval |= $SP5[($work >>  8) & 0x3f];
    $fval |= $SP3[($work >> 16) & 0x3f];
    $fval |= $SP1[($work >> 24) & 0x3f];

    // printf("fval=%lu\n", $fval);

    $work  = $leftt ^ $keys[$i++];

    // printf("work=%lu\n", $work);

    $fval |= $SP8[ $work & 0x3f];
    $fval |= $SP6[($work >>  8) & 0x3f];
    $fval |= $SP4[($work >> 16) & 0x3f];
    $fval |= $SP2[($work >> 24) & 0x3f];

    // printf("fval=%lu\n", $fval); $right ^= $fval;

    // printf("right=%lu\n", $right);
    }
    $right = ($right << 31) | ($right >> 1);
    $work = ($leftt ^ $right) & 0xaaaaaaaa;
    $leftt ^= $work;
    $right ^= $work;
    $leftt = ($leftt << 31) | ($leftt >> 1);
    $work = (($leftt >> 8) ^ $right) & 0x00ff00ff;
    $right ^= $work;
    $leftt ^= ($work << 8);
    $work = (($leftt >> 2) ^ $right) & 0x33333333;
    $right ^= $work;
    $leftt ^= ($work << 2);
    $work = (($right >> 16) ^ $leftt) & 0x0000ffff;
    $leftt ^= $work;
    $right ^= ($work << 16);
    $work = (($right >> 4) ^ $leftt) & 0x0f0f0f0f;
    $leftt ^= $work;
    $right ^= ($work << 4);
    $block[0] = $right;
    $block[1] = $leftt;
    }
      

  9.   

    function des3key($hexkey, /* unsigned char[24] */
       $mode)
    {
    global $KnR,$Kn3;

    $first = $hexkey;
    $third = $hexkey;
    $temp = array(0=>16);   
    $revmod = 0; if( $mode == EN0 ) {
    $revmod = DE1;
    $first = $hexkey;
    $third = array($hexkey[16],$hexkey[17],$hexkey[18],$hexkey[19],$hexkey[20],$hexkey[21],$hexkey[22],$hexkey[23]);
    }
    else {
    $revmod = EN0;
    $first = array($hexkey[16],$hexkey[17],$hexkey[18],$hexkey[19],$hexkey[20],$hexkey[21],$hexkey[22],$hexkey[23]);
    $third = $hexkey;
    }

    for($i=0;$i<16;$i++)
       $temp[$i] = $hexkey[$i+8];   
       
    deskey($temp, $revmod);
    cpkey($KnR);
    deskey($third, $mode);
    cpkey($Kn3);
    deskey($first, $mode);
    }
    function scrunch($outof, &$into)
    {
    $into[0]  = (ord($outof[0]) & 0xff) << 24;
    $into[0] |= (ord($outof[1]) & 0xff) << 16;
    $into[0] |= (ord($outof[2]) & 0xff) << 8;
    $into[0] |= (ord($outof[3]) & 0xff);
    $into[1]  = (ord($outof[4]) & 0xff) << 24;
    $into[1] |= (ord($outof[5]) & 0xff) << 16;
    $into[1] |= (ord($outof[6]) & 0xff) << 8;
    $into[1] |= (ord($outof[7]) & 0xff);
    }function unscrun($outof, &$into)
    {
    $into[0] = ($outof[0] >> 24) & 0xff;
    $into[1] = ($outof[0] >> 16) & 0xff;
    $into[2] = ($outof[0] >>  8) & 0xff;
    $into[3] =  $outof[0]      & 0xff;
    $into[4] = ($outof[1] >> 24) & 0xff;
    $into[5] = ($outof[1] >> 16) & 0xff;
    $into[6] = ($outof[1] >>  8) & 0xff;
    $into[7] =  $outof[1]      & 0xff;
    }/* amateur theatrics */
    function D3des($from, /* unsigned char[24] */
       &$into) /* unsigned char[24] */
    {
    global $KnL;

    $swap = 0;
    $leftt = array(0,0);
    $middl = array(0,0);
    $right = array(0,0);

    $from_left = array($from[0],$from[1],$from[2],$from[3],$from[4],$from[5],$from[6],$from[7]);
    $from_mid = array($from[8],$from[9],$from[10],$from[11],$from[12],$from[13],$from[14],$from[15]);
    $from_right = array($from[16],$from[17],$from[18],$from[19],$from[20],$from[21],$from[22],$from[23]);

    scrunch($from_left, $leftt);
    scrunch($from_mid, $middl);
    scrunch($from_right, $right);

    desfunc($leftt, $KnL);
    desfunc($middl, $KnL);
    desfunc($right, $KnL); printf("%x,%x,%x,%x\n\n", $leftt[0], $leftt[1], $middl[0], $middl[1], $right[0], $right[1]);
    /*

    swap = leftt[1];
    leftt[1] = middl[0];
    middl[0] = swap;
    swap = middl[1];
    middl[1] = right[0];
    right[0] = swap;
    desfunc(leftt, KnR);
    desfunc(middl, KnR);
    desfunc(right, KnR);
    swap = leftt[1];
    leftt[1] = middl[0];
    middl[0] = swap;
    swap = middl[1];
    middl[1] = right[0];
    right[0] = swap;
    desfunc(leftt, Kn3);
    desfunc(middl, Kn3);
    desfunc(right, Kn3);
    unscrun(leftt, into);
    unscrun(middl, &into[8]);
    unscrun(right, &into[16]);
    return;
    */
    }
    echo  "<PRE>";
    $Buffer = "123456789012345678901234";
    $len = strlen($Buffer);$desKey = array(0x77,0x91,0x07,0x4B,0xBB,0x23,0x70,0xE7,
    0x98,0xB4,0x86,0x91,0x1C,0xE9,0xE1,0xCB,
    0xC8,0x0F,0x31,0xDA,0xE7,0x17,0x2E,0xDF); des3key($desKey, EN0);D3des($Buffer, $Buffer);/* // 显示十六进制
    char temp1[100], temp[1024] = {0};
    for(i=0;i<len;i++)
    {
    sprintf(temp1, "%02x", (unsigned char)Buffer[i]);
    strcat(temp, temp1);
    }
    */
    ?>
      

  10.   

    在Unix服务器测试结果也不正确, 应该不是服务器的问题吧.结果:
    [0]: 3732172454,1037509577,33489100,3750403596
    work=4260932064, 28=3221225472, 4=4260932064
    test1: 234400224
    test2: 4260932065
      

  11.   

    <?php// leftt用lu输出是3750403596 , 但用var_dump显示是int(-544563700)
    $leftt = -544563700; // int$temp = $leftt/16;//echo $temp;
    printf("%lu\n", $temp);?>
      

  12.   

    我的5.2.3也没错
    234400224.75
    234400224.75
    呵呵,如果楼主的结果不对就换版本嘛!php有版本有bug也不足为奇。
      

  13.   

    <?php// leftt用lu输出是3750403596 , 但用var_dump显示是int(-544563700)
    $leftt = -544563700; // int$temp = $leftt/16;//echo $temp;
    printf("%lu\n", $temp);?>这个结果也是234400224.75 , 234400224.75 ????? 不可能吧.
      

  14.   

    你的数都是超范围的,用c也计算不正确。你可以用"BC math 高精度数学函数"(见手册)

    $leftt = -544563700; // int
    echo bcdiv($leftt, 16, 3);结果:-34035231.250
      

  15.   

    234400224.75 
    234400224.75 
    指的是
    $temp   =   3750403596   /   16;   
      

  16.   

    问题已解决!谢谢大家了!<?php$temp = 3750403596/16;
    echo $temp."<br>";$leftt = -544563700; // int
    //$leftt = 3750403596; // float$temp2 = floatval(sprintf("%lu",$leftt)); var_dump($temp2);$temp = $temp2/16;//echo $temp;
    printf("%lu\n", $temp);?>
    结果:
    234400224.75
    float(3750403596) 234400224