JS
S
JavaScriptMotivation: Array operations are faster with TypedArrays. Rules: If arrays are generally small < 1.000.000, use Array; If arrays >= 1.000.000 use TypedArrays Basic Arrays are 64 bit (higher precision then Float32Array typed Array) Create a basic floating-point array (32-bit floating point numbers) Can be created from: an ArrayBuffer, from a TypedArray, from an Iterable, from an Array. Computer Number: 4 bytes (32 bits) Maximum: 231 − 1 = 2,147,483,647 -- Sign exponent: 8 bits Facrtion: 23 bits
1// Number, is a 64-bit floating point IEEE 754 number.
2Number.MIN_SAFE_INTEGER;
3Number.MAX_SAFE_INTEGER;
4var MAX_INT = 4294967295; (safe for bit shifting)
5
6// Common Types
7Float32Array (32-bit floating point float) 2,147,483,647
8Float64Array (64-bit floating point double) 9007199254740991
9Uint32Array (32 bit unsigned long)
10Int32Array (32-bit signed integer long)
11Uint16Array (16-bit unsigned integer short) // 0 - 65535
12Int16Array (16-bit signed short) // 0 - 32768
13
14// Example of Float32
15var float32 = new Float32Array(2);
16float32[0] = 42;
17console.log(float32.length); // 2
18console.log(float32.BYTES_PER_ELEMENT); // 4
19Created on 4/2/2021