mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
add writeFloat() and writeDouble()
This commit is contained in:
parent
cbb9d58d6e
commit
20ddb355a9
@ -54,10 +54,10 @@ class WasmOutputStream extends FilterOutputStream {
|
|||||||
* if an I/O error occurs.
|
* if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
void writeInt32( int value ) throws IOException {
|
void writeInt32( int value ) throws IOException {
|
||||||
write( (value >>> 0) & 0xFF );
|
write( value >>> 0 );
|
||||||
write( (value >>> 8) & 0xFF );
|
write( value >>> 8 );
|
||||||
write( (value >>> 16) & 0xFF );
|
write( value >>> 16 );
|
||||||
write( (value >>> 24) & 0xFF );
|
write( value >>> 24 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,6 +105,48 @@ class WasmOutputStream extends FilterOutputStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an float value.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* the value
|
||||||
|
* @throws IOException
|
||||||
|
* if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
void writeFloat( float value ) throws IOException {
|
||||||
|
int i = Float.floatToIntBits( value );
|
||||||
|
writeInt( i );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an integer value as big endian (ever 4 bytes).
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* the value
|
||||||
|
* @throws IOException
|
||||||
|
* if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
void writeInt( int value ) throws IOException {
|
||||||
|
write( value >>> 24 );
|
||||||
|
write( value >>> 16 );
|
||||||
|
write( value >>> 8 );
|
||||||
|
write( value >>> 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an double value.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* the value
|
||||||
|
* @throws IOException
|
||||||
|
* if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
void writeDouble( double value ) throws IOException {
|
||||||
|
long l = Double.doubleToLongBits(value);
|
||||||
|
writeInt( (int)(l >>> l) );
|
||||||
|
writeInt( (int)l );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a section with header and data.
|
* Write a section with header and data.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user