Int32Array

Typed array constructor which returns a typed array representing an array of twos-complement 32-bit signed integers in the platform byte order.

Usage

var Int32Array = require( '@stdlib/array/int32' );

Int32Array()

A typed array constructor which returns a typed array representing an array of twos-complement 32-bit signed integers in the platform byte order.

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

Int32Array( length )

Returns a typed array having a specified length.

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

Int32Array( 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 Int32Array( arr1 );
// returns <Int32Array>[ 5, 5, 5 ]

Int32Array( obj )

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

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

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

Returns a typed array view of an ArrayBuffer.

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

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

Properties

Int32Array.BYTES_PER_ELEMENT

Number of bytes per view element.

var nbytes = Int32Array.BYTES_PER_ELEMENT;
// returns 4

Int32Array.name

Typed array constructor name.

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

Int32Array.prototype.buffer

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

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

Int32Array.prototype.byteLength

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

var arr = new Int32Array( 5 );
var byteLength = arr.byteLength;
// returns 20

Int32Array.prototype.byteOffset

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

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

Int32Array.prototype.length

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

var arr = new Int32Array( 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/int32' );

var arr;
var i;

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