Skip to content

ByteArray#endian will help you #25

@GoogleCodeExporter

Description

@GoogleCodeExporter

For example

class CodedOutputStream

public function writeRawLittleEndian64(value:Number):void {
    //tricky: BigInteger takes an array with heaviest byte first!
    //reverse from the stream

    var bytes:ByteArray = value.toByteArray();
    var b8:int = bytes.readByte();
    var b7:int = bytes.readByte();
    var b6:int = bytes.readByte();
    var b5:int = bytes.readByte();
    var b4:int = bytes.readByte();
    var b3:int = bytes.readByte();
    var b2:int = bytes.readByte();
    var b1:int = bytes.readByte();

    writeRawByte(b1);
    writeRawByte(b2);
    writeRawByte(b3);
    writeRawByte(b4);
    writeRawByte(b5);
    writeRawByte(b6);
    writeRawByte(b7);
    writeRawByte(b8);
}

Get ride to 
public function writeRawLittleEndian64(value:Number):void {
    //var endian:String = this.output.endian; // save if need
    this.output.endian = Endian.BIG_ENDIAN;
    this.output.writeByte(value);
    //this.output.endian = endian; // restore
}

Original issue reported on code.google.com by goodcore...@gmail.com on 19 Nov 2010 at 12:33

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions