public static long bytesTolong(byte [] pbArSource,int piStartPos)
  {
    if(piStartPos<0 || pbArSource == null || pbArSource.length < piStartPos+8-1)
      return 0;
    return bytesTolong(pbArSource[piStartPos+0],pbArSource[piStartPos+1],
                        pbArSource[piStartPos+2],pbArSource[piStartPos+3],
                        pbArSource[piStartPos+4],pbArSource[piStartPos+5],
                        pbArSource[piStartPos+6],pbArSource[piStartPos+7]);
  }/**
   * Convert 8 bytes to an long value.
   * @param pb0 the LIB(Least Important Byte) to MIB(Most Important Byte) of an long.
   * @param pb1 the LIB(Least Important Byte) to MIB(Most Important Byte) of an long.
   * @param pb2 the LIB(Least Important Byte) to MIB(Most Important Byte) of an long.
   * @param pb3 the LIB(Least Important Byte) to MIB(Most Important Byte) of an long.
   * @param pb4 the LIB(Least Important Byte) to MIB(Most Important Byte) of an long.
   * @param pb5 the LIB(Least Important Byte) to MIB(Most Important Byte) of an long.
   * @param pb6 the LIB(Least Important Byte) to MIB(Most Important Byte) of an long.
   * @param pb7 the LIB(Least Important Byte) to MIB(Most Important Byte) of an long.
   * @return the long value converted.
   * @see com.saili.util.DataConverter#bytesTolong(byte [] pbArSource,int piStartPos)
   * @see com.saili.util.DataConverter#longTobytes(long plNumber,byte[] pbArDest,int piStartPos)   */
  public static long  bytesTolong(byte pb0,byte pb1,byte pb2,byte pb3,byte pb4,byte pb5,byte pb6,byte pb7)
  {    long i = 0, out = 0;
    if(pb0<0) i = 256+pb0; else i = pb0;
      out += i;
    if(pb1<0) i = 256+pb1; else i = pb1;
      out += (i<<8);
    if(pb2<0) i = 256+pb2; else i = pb2;
      out += (i<<16);
    if(pb3<0) i = 256+pb3; else i = pb3;
      out += (i<<24);
    if(pb4<0) i = 256+pb4; else i = pb4;
      out += (i<<32);
    if(pb5<0) i = 256+pb5; else i = pb5;
      out += (i<<40);
    if(pb6<0) i = 256+pb6; else i = pb6;
      out += (i<<48);
    if(pb7<0) i = 256+pb7; else i = pb7;
      out += (i<<56);
    return out;
  }

解决方案 »

  1.   

    我记得java的double是64位的?float才是32位,查书:
    The floating-point types are float and double, which are conceptually associated with the single-precision 32-bit and double-precision 64-bit format IEEE 754 values and operations as specified in IEEE Standard for Binary Floating-Point Arithmetic, ANSI/IEEE Standard 754-1985 (IEEE, New York).与vc的不同之处应该在于大头小头:big-endian,little-endian我也忘了那个是big-endian那个是little-endian了.
    反正,vc写的,java要倒着读,java写的,vc要倒着读