当前位置: 首页>>代码示例>>Java>>正文


Java ByteBuffer.getFloat方法代码示例

本文整理汇总了Java中java.nio.ByteBuffer.getFloat方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuffer.getFloat方法的具体用法?Java ByteBuffer.getFloat怎么用?Java ByteBuffer.getFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.getFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFloatGet

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Test(dataProvider = "floatViewProvider")
public void testFloatGet(String desc, IntFunction<ByteBuffer> fbb,
                         Function<ByteBuffer, FloatBuffer> fbi) {
    ByteBuffer bb = allocate(fbb);
    FloatBuffer vb = fbi.apply(bb);
    int o = bb.position();

    for (int i = 0; i < vb.limit(); i++) {
        float fromBytes = getFloatFromBytes(bb, o + i * 4);
        float fromMethodView = bb.getFloat(o + i * 4);
        assertValues(i, fromBytes, fromMethodView, bb);

        float fromBufferView = vb.get(i);
        assertValues(i, fromMethodView, fromBufferView, bb, vb);
    }

    for (int i = 0; i < vb.limit(); i++) {
        float v = getFloatFromBytes(bb, o + i * 4);
        float a = bb.getFloat();
        assertValues(i, v, a, bb);

        float b = vb.get();
        assertValues(i, a, b, bb, vb);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ByteBufferViews.java

示例2: updateEntity

import java.nio.ByteBuffer; //导入方法依赖的package包/类
private void updateEntity(String participantId, ByteBuffer wrap) {
    Entity entity = null;
    for (Entity syncedEntity : syncedEntities) {
        if (idMapper.get(syncedEntity).participantId.equals(participantId)) {
            entity = syncedEntity;
            break;
        }
    }
    if (entity == null) {
        Gdx.app.debug(TAG, "updateEntity: NULL");
        return;
    }
    TransformComponent transformComponent = transformMapper.get(entity);
    MovementComponent movement = movementMapper.get(entity);
    if (transformComponent == null || movement == null) return;
    transformComponent.position.x = wrap.getFloat();
    transformComponent.position.y = wrap.getFloat();
    transformComponent.rotation.x = wrap.getFloat();
    transformComponent.rotation.y = wrap.getFloat();
    movement.velocity.x = wrap.getFloat();
    movement.velocity.y = wrap.getFloat();
    movement.acceleration.x = wrap.getFloat();
    movement.acceleration.y = wrap.getFloat();
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:25,代码来源:NetworkSystem.java

示例3: unalignedReadSnippet

import java.nio.ByteBuffer; //导入方法依赖的package包/类
Ret unalignedReadSnippet(byte[] arg) {
    ByteBuffer buffer = makeDirect(arg, byteOrder);

    Ret ret = new Ret();
    ret.byteValue = buffer.get();
    ret.shortValue = buffer.getShort();
    ret.intValue = buffer.getInt();
    ret.longValue = buffer.getLong();
    ret.doubleValue = buffer.getDouble();
    ret.floatValue = buffer.getFloat();

    return ret;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:DirectByteBufferTest.java

示例4: getDicPrimitiveArray

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override                                                                                                      public PrimitiveObject[] getDicPrimitiveArray( final byte[] buffer , final int start , final int length ) throws IOException{
  int size = length / Float.BYTES;
  PrimitiveObject[] result = new PrimitiveObject[size];
  ByteBuffer wrapBuffer = ByteBuffer.wrap( buffer , start , length );
  wrapBuffer.getFloat();
  for( int i = 1 ; i < size ; i++ ){
    result[i] = new FloatObj( wrapBuffer.getFloat() );
  }

  return result;
}
 
开发者ID:yahoojapan,项目名称:multiple-dimension-spread,代码行数:12,代码来源:OptimizeFloatColumnBinaryMaker.java

示例5: decodeInternal

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
Float decodeInternal(ByteBuffer input) {
  if (input == null || input.remaining() == 0) return 0.0f;
  if (input.remaining() != 4)
    throw new InvalidTypeException(
        "Invalid 32-bits float value, expecting 4 bytes but got " + input.remaining());

  return input.getFloat(input.position());
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:10,代码来源:CqlMapper.java

示例6: getDoubleFromByteBuffer

import java.nio.ByteBuffer; //导入方法依赖的package包/类
public static double getDoubleFromByteBuffer(ByteBuffer byteBuffer)
{
	byte flag = byteBuffer.get();
	double ret = 0;

	if (flag == FLOAT_VALUE)
		ret = byteBuffer.getFloat();
	else
		ret = byteBuffer.getDouble();

	return (ret);
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:13,代码来源:ValueSerializer.java

示例7: read

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
public void read(ByteBuffer buffer) {
    weaponid = buffer.get();
    x = buffer.getFloat();
    y = buffer.getFloat();
    rotation = buffer.getFloat();
    playerid = buffer.getInt();
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:9,代码来源:Packets.java

示例8: alignedReadSnippet

import java.nio.ByteBuffer; //导入方法依赖的package包/类
Ret alignedReadSnippet(byte[] arg) {
    ByteBuffer buffer = makeDirect(arg, byteOrder);

    Ret ret = new Ret();
    ret.byteValue = buffer.get();
    ret.byteValue += buffer.get();
    ret.shortValue = buffer.getShort();
    ret.intValue = buffer.getInt();
    ret.longValue = buffer.getLong();
    ret.doubleValue = buffer.getDouble();
    ret.floatValue = buffer.getFloat();

    return ret;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:DirectByteBufferTest.java

示例9: DataRepresentationTemplate50

import java.nio.ByteBuffer; //导入方法依赖的package包/类
public DataRepresentationTemplate50(ByteBuffer byteBuffer) {

		referenceValueR = byteBuffer.getFloat();
		binaryScaleFactorE = GribSection.correctNegativeShort(byteBuffer.getShort());
		decimalScaleFactorD = GribSection.correctNegativeShort(byteBuffer.getShort());
		numberBits = byteBuffer.get();
		typeOfField = byteBuffer.get();
	}
 
开发者ID:philippphb,项目名称:GRIB2Tools,代码行数:9,代码来源:DataRepresentationTemplate50.java

示例10: unalignedReadSnippet

import java.nio.ByteBuffer; //导入方法依赖的package包/类
Ret unalignedReadSnippet(byte[] arg) {
    ByteBuffer buffer = ByteBuffer.wrap(arg).order(byteOrder);

    Ret ret = new Ret();
    ret.byteValue = buffer.get();
    ret.shortValue = buffer.getShort();
    ret.intValue = buffer.getInt();
    ret.longValue = buffer.getLong();
    ret.doubleValue = buffer.getDouble();
    ret.floatValue = buffer.getFloat();

    return ret;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ByteBufferTest.java

示例11: toFloat

import java.nio.ByteBuffer; //导入方法依赖的package包/类
public static float toFloat(ByteBuffer bytes)
{
    return bytes.getFloat(bytes.position());
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:5,代码来源:ByteBufferUtil.java

示例12: loadInMemoryStorage

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
public void loadInMemoryStorage( final ColumnBinary columnBinary , final IMemoryAllocator allocator ) throws IOException{
  ByteBuffer wrapBuffer = ByteBuffer.wrap( columnBinary.binary , columnBinary.binaryStart , columnBinary.binaryLength );
  switch( columnBinary.columnType ){
    case BOOLEAN:
      boolean booleanObj = wrapBuffer.get() == 1;
      for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
        allocator.setBoolean( i , booleanObj );
      }
      break;
    case BYTE:
      byte byteObj = wrapBuffer.get();
      for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
        allocator.setByte( i , byteObj );
      }
      break;
    case SHORT:
      short shortObj = wrapBuffer.getShort();
      for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
        allocator.setShort( i , shortObj );
      }
      break;
    case INTEGER:
      int intObj = wrapBuffer.getInt();
      for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
        allocator.setInteger( i , intObj );
      }
      break;
    case LONG:
      long longObj = wrapBuffer.getLong();
      for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
        allocator.setLong( i , longObj );
      }
      break;
    case FLOAT:
      float floatObj = wrapBuffer.getFloat();
      for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
        allocator.setFloat( i , floatObj );
      }
      break;
    case DOUBLE:
      double doubleObj = wrapBuffer.getDouble();
      for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
        allocator.setDouble( i , doubleObj );
      }
      break;
    case STRING:
      int stringLength = wrapBuffer.getInt();
      byte[] stringBytes = new byte[stringLength];
      wrapBuffer.get( stringBytes );
      String utf8 = new String( stringBytes , "UTF-8" );
      for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
        allocator.setString( i , utf8 );
      }
      break;
    case BYTES:
      int byteLength = wrapBuffer.getInt();
      byte[] byteBytes = new byte[byteLength];
      wrapBuffer.get( byteBytes );
      for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
        allocator.setBytes( i , byteBytes );
      }
      break;
    default:
      throw new IOException( "Unknown primitive type." );
  }
  allocator.setValueCount( columnBinary.rowCount );
}
 
开发者ID:yahoojapan,项目名称:multiple-dimension-spread,代码行数:69,代码来源:ConstantColumnBinaryMaker.java

示例13: binDecode_FLOAT

import java.nio.ByteBuffer; //导入方法依赖的package包/类
private DataWrapper binDecode_FLOAT(ByteBuffer buffer) {
    float floatValue = buffer.getFloat();
    return new DataWrapper(DataType.FLOAT, Float.valueOf(floatValue));
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:5,代码来源:DefaultSFSDataSerializer.java

示例14: decodeData

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
public void decodeData(ByteBuffer buffer, int length) {
	data = buffer.getFloat();
	addDataLength(length);
}
 
开发者ID:mustafabayar,项目名称:EasyDiameter,代码行数:6,代码来源:Float32AVP.java

示例15: LogItem

import java.nio.ByteBuffer; //导入方法依赖的package包/类
public LogItem(byte[] in, int length) throws UnsupportedEncodingException {
    ByteBuffer bb = ByteBuffer.wrap(in, 0, length);
    bb.get(); // ignore version
    logtime = bb.getLong();
    mVerbosityLevel = bb.getInt();
    mLevel = VpnStatus.LogLevel.getEnumByValue(bb.getInt());
    mRessourceId = bb.getInt();
    int len = bb.getInt();
    if (len == 0) {
        mMessage = null;
    } else {
        if (len > bb.remaining()) throw new IndexOutOfBoundsException("String length " + len + " is bigger than remaining bytes " + bb.remaining());
        byte[] utf8bytes = new byte[len];
        bb.get(utf8bytes);
        mMessage = new String(utf8bytes, "UTF-8");
    }
    int numArgs = bb.getInt();
    if (numArgs > 30) {
        throw new IndexOutOfBoundsException("Too many arguments for Logitem to unmarschal");
    }
    if (numArgs == 0) {
        mArgs = null;
    } else {
        mArgs = new Object[numArgs];
        for (int i = 0; i < numArgs; i++) {
            char type = bb.getChar();
            switch (type) {
                case 's':
                    mArgs[i] = unmarschalString(bb);
                    break;
                case 'i':
                    mArgs[i] = bb.getInt();
                    break;
                case 'd':
                    mArgs[i] = bb.getDouble();
                    break;
                case 'f':
                    mArgs[i] = bb.getFloat();
                    break;
                case 'l':
                    mArgs[i] = bb.getLong();
                    break;
                case '0':
                    mArgs[i] = null;
                    break;
                default:
                    throw new UnsupportedEncodingException("Unknown format type: " + type);
            }
        }
    }
    if (bb.hasRemaining()) throw new UnsupportedEncodingException(bb.remaining() + " bytes left after unmarshaling everything");
}
 
开发者ID:akashdeepsingh9988,项目名称:Cybernet-VPN,代码行数:53,代码来源:LogItem.java


注:本文中的java.nio.ByteBuffer.getFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。