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

Quelle  round-float32.js   Sprache: JAVA

 
// Bug 1073910
(function() {
    function roundf(y) {
        return Math.round(Math.fround(y));
    }

    var x = -1;
    assertEq(roundf(x), x);
    assertEq(roundf(x), x);

    var x = -2;
    assertEq(roundf(x), x);
    assertEq(roundf(x), x);

    var x = -1024;
    assertEq(roundf(x), x);

    var x = -14680050;
    assertEq(roundf(x), Math.fround(x));

    var x = -8388610;
    assertEq(roundf(x), Math.fround(x));
})();

// Bug 1000606
(function() {
    function f() {
        var d = Math.fround(0.4999999701976776);
        return Math.round(d);
    }
    assertEq(f(), f());

    function g() {
        var c = Math.fround(8886111);
        return Math.round(c);
    }
    assertEq(g(), g());
})();

// Bug 1124485
(function() {
    function h(x) {
        var y = Math.fround(x);
        assertEq(y, Math.pow(y, 1));
    }
    h(0);
    h(2147483647);
})();

// Bug 1122344
(function() {
    function f() {
        return Math.round(Math.fround(-13527757));
    };
    assertEq(f(), f());
})();

(function() {
    // Test values around -0.5 and +0.5
    var f32 = new Float32Array(1);
    var i32 = new Int32Array(f32.buffer);

    function round(x) { return Math.round(x); }
    function roundf(x) { return Math.round(Math.fround(x)); }

    // Warm up
    round(2.5);
    round(3.5);
    roundf(2.5);
    roundf(3.5);

    f32[0] = 0.5;
    i32[0] += 1;
    print('0.5+e =', f32[0]);

    var x = f32[0];
    assertEq(round(x), 1);
    assertEq(roundf(x), 1);

    f32[0] = 0.5;
    i32[0] -= 1;
    print('0.5-e =', f32[0]);

    var x = f32[0];
    assertEq(round(x), 0);
    assertEq(roundf(x), 0);

    f32[0] = -0.5;
    i32[0] += 1;
    print('-0.5-e =', f32[0]);

    var x = f32[0];
    assertEq(round(x), -1);
    assertEq(roundf(x), -1);

    f32[0] = -0.5;
    i32[0] -= 1;
    print('-0.5+e =', f32[0]);

    var x = f32[0];
    assertEq(round(x), -0);
    assertEq(roundf(x), -0);
})();

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

¤ Dauer der Verarbeitung: 0.1 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.