Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  pow-constant-power.js

  Sprache: JAVA
 

// Ion provides specialisations when Math.pow() resp. the **-operator is used
// with a constant power of one of [-0.5, 0.5, 1, 2, 3, 4].

function test(x, y, z) {
    function pow(x, y) { return `Math.pow(${x}, ${y})` };
    function exp(x, y) { return `((${x}) ** ${y})` };

    function make(fn, x, y, z) {
        return Function(`
            // Load from array to prevent constant-folding.
            // (Ion is currently not smart enough to realise that both array
            // values are the same.)
            var xs = [${x}, ${x}];
            var zs = [${z}, ${z}];
            for (var i = 0; i < 1000; ++i) {
                assertEq(${fn("xs[i & 1]", y)}, zs[i & 1]);
            }
        `);
    }

    function double(v) {
        // NB: numberToDouble() always returns a double value.
        return `numberToDouble(${v})`;
    }

    function addTests(fn) {
        tests.push(make(fn, x, y, z));
        tests.push(make(fn, x, double(y), z));
        tests.push(make(fn, double(x), y, z));
        tests.push(make(fn, double(x), double(y), z));
    }

    var tests = [];
    addTests(pow);
    addTests(exp);

    for (var i = 0; i < tests.length; ++i) {
        for (var j = 0; j < 2; ++j) {
            tests[i]();
        }
    }
}

// Make sure the tests below test int32 and double return values.

// Math.pow(x, -0.5)
test( 1, -0.51);
test(16, -0.50.25);

// Math.pow(x, 0.5)
test(160.54);
test( 20.5, Math.SQRT2);

// Math.pow(x, 1)
test(5,   15);
test(0.510.5);

// Math.pow(x, 2)
test(5,   225);
test(0.520.25);

// Math.pow(x, 3)
test(5,   3125);
test(0.530.125);

// Math.pow(x, 3)
test(5,   4625);
test(0.540.0625);

Messung V0.5 in Prozent
C=81 H=76 G=78

¤ Dauer der Verarbeitung: 0.18 Sekunden  (vorverarbeitet am  2026-06-08) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik