Skip to content

Latest commit

 

History

History

uint16

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Uint16Array

Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.

Usage

var Uint16Array = require( '@stdlib/array/uint16' );

Uint16Array()

A typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.

var arr = new Uint16Array();
// returns <Uint16Array>

Uint16Array( length )

Returns a typed array having a specified length.

var arr = new Uint16Array( 5 );
// returns <Uint16Array>[ 0, 0, 0, 0, 0 ]

Uint16Array( typedarray )

Creates a typed array from another typed array.

var Float32Array = require( '@stdlib/array/float32' );

var arr1 = new Float32Array( [ 5.0, 5.0, 5.0 ] );
var arr2 = new Uint16Array( arr1 );
// returns <Uint16Array>[ 5, 5, 5 ]

Uint16Array( obj )

Creates a typed array from an array-like object or iterable.

var arr = new Uint16Array( [ 5.0, 5.0, 5.0 ] );
// returns <Uint16Array>[ 5, 5, 5 ]

Uint16Array( buffer[, byteOffset[, length]] )

Returns a typed array view of an ArrayBuffer.

var ArrayBuffer = require( '@stdlib/array/buffer' );

var buf = new ArrayBuffer( 8 );
var arr = new Uint16Array( buf, 0, 4 );
// returns <Uint16Array>[ 0, 0, 0, 0 ]

Properties

Uint16Array.BYTES_PER_ELEMENT

Number of bytes per view element.

var nbytes = Uint16Array.BYTES_PER_ELEMENT;
// returns 2

Uint16Array.name

Typed array constructor name.

var str = Uint16Array.name;
// returns 'Uint16Array'

Uint16Array.prototype.buffer

Read-only property which returns the ArrayBuffer referenced by the typed array.

var arr = new Uint16Array( 5 );
var buf = arr.buffer;
// returns <ArrayBuffer>

Uint16Array.prototype.byteLength

Read-only property which returns the length (in bytes) of the typed array.

var arr = new Uint16Array( 5 );
var byteLength = arr.byteLength;
// returns 10

Uint16Array.prototype.byteOffset

Read-only property which returns the offset (in bytes) of the typed array from the start of its ArrayBuffer.

var arr = new Uint16Array( 5 );
var byteOffset = arr.byteOffset;
// returns 0

Uint16Array.prototype.length

Read-only property which returns the number of view elements.

var arr = new Uint16Array( 5 );
var len = arr.length;
// returns 5

Methods

TODO: add methods


Examples

var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var ctor = require( '@stdlib/array/uint16' );

var arr;
var i;

arr = new ctor( 10 );
for ( i = 0; i < arr.length; i++ ) {
    arr[ i ] = round( randu()*100.0 );
}
console.log( arr );