Skip to content

Files

Latest commit

 

History

History

float32

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Oct 2, 2018
Sep 9, 2018
Feb 2, 2018
Feb 10, 2018
Oct 2, 2018
Feb 2, 2018
Nov 22, 2017

Float32Array

Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order.

Usage

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

Float32Array()

A typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order.

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

Float32Array( length )

Returns a typed array having a specified length.

var arr = new Float32Array( 5 );
// returns <Float32Array>[ 0.0, 0.0, 0.0, 0.0, 0.0 ]

Float32Array( typedarray )

Creates a typed array from another typed array.

var Float64Array = require( '@stdlib/array/float64' );

var arr1 = new Float64Array( [ 0.5, 0.5, 0.5 ] );
var arr2 = new Float32Array( arr1 );
// returns <Float32Array>[ 0.5, 0.5, 0.5 ]

Float32Array( obj )

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

var arr = new Float32Array( [ 0.5, 0.5, 0.5 ] );
// returns <Float32Array>[ 0.5, 0.5, 0.5 ]

Float32Array( 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 Float32Array( buf, 0, 4 );
// returns <Float32Array>[ 0.0, 0.0, 0.0, 0.0 ]

Properties

Float32Array.BYTES_PER_ELEMENT

Number of bytes per view element.

var nbytes = Float32Array.BYTES_PER_ELEMENT;
// returns 4

Float32Array.name

Typed array constructor name.

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

Float32Array.prototype.buffer

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

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

Float32Array.prototype.byteLength

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

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

Float32Array.prototype.byteOffset

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

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

Float32Array.prototype.length

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

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

Methods

TODO: add methods


Examples

var randu = require( '@stdlib/random/base/randu' );
var ctor = require( '@stdlib/array/float32' );

var arr;
var i;

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