Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/js/src/jit-test/lib/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  dataview.js   Sprache: JAVA

 
function typeName(typedArrayCtor) {
  return typedArrayCtor.name.slice(0, -"Array".length);
}

const nativeIsLittleEndian = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;

function toEndianess(type, v, littleEndian) {
  // Disable Ion compilation to call the native, non-inlined DataView functions.
  with ({}); // no-ion
  assertEq(inIon() !== truetrue);

  let dv = new DataView(new ArrayBuffer(type.BYTES_PER_ELEMENT));

  let name = typeName(type);
  dv[`set${name}`](0, v, nativeIsLittleEndian);
  return dv[`get${name}`](0, littleEndian);
}

function toLittleEndian(type, v) {
  return toEndianess(type, v, true);
}

function toBigEndian(type, v) {
  return toEndianess(type, v, false);
}

// Shared test data for various DataView tests.
function createTestData() {
  const tests = [
    {
      type: Int8Array,
      values: [-128, -127, -2, -1, 0, 1, 2, 126, 127],
    },
    {
      type: Uint8Array,
      values: [0, 1, 2, 126, 127, 128, 254, 255],
    },
    {
      type: Int16Array,
      values: [-32768, -32767, -2, -1, 0, 1, 2, 32766, 32767],
    },
    {
      type: Uint16Array,
      values: [0, 1, 2, 32766, 32767, 32768, 65534, 65535],
    },
    {
      type: Int32Array,
      values: [-2147483648, -2147483647, -2, -1, 0, 1, 2, 2147483646, 2147483647],
    },
    {
      type: Uint32Array,
      values: [0, 1, 2, 2147483646, 2147483647],  // Representable as Int32
    },
    {
      type: Uint32Array,
      values: [0, 1, 2, 2147483646, 2147483647, 2147483648, 4294967294, 4294967295],
    },
    {
      type: Float16Array,
      values: [-NaN, -Infinity, -0.5, -0, +0, 0.5, Infinity, NaN],
    },
    {
      type: Float32Array,
      values: [-NaN, -Infinity, -0.5, -0, +0, 0.5, Infinity, NaN],
    },
    {
      type: Float64Array,
      values: [-NaN, -Infinity, -0.5, -0, +0, 0.5, Infinity, NaN],
    },
    {
      type: BigInt64Array,
      values: [-9223372036854775808n, -9223372036854775807n, -2n, -1n, 0n, 1n, 2n, 9223372036854775806n, 9223372036854775807n],
    },
    {
      type: BigUint64Array,
      values: [0n, 1n, 2n, 9223372036854775806n, 9223372036854775807n, 9223372036854775808n, 18446744073709551614n, 18446744073709551615n],
    },
  ];

  tests.forEach(data => {
    data.littleEndian = data.values.map(v => toLittleEndian(data.type, v));
    data.bigEndian = data.values.map(v => toBigEndian(data.type, v));
  });

  return tests;
}

Messung V0.5
C=92 H=95 G=93

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.