mirror of
https://github.com/MikeMcl/big.js.git
synced 2026-01-25 16:04:15 +00:00
Add optional rounding mode parameter to `toExponential`, `toFixed` and `toPrecision`. Add a strict mode to disallow imprecise number/Big conversions when `Big.strict = true`. Add `toNumber` method. Add `prec` method to round a Big to a specified number of significant digits. Add version selector to API documentation. Change `toJSON` to return exponential format. Remove *big.min.js*. Remove `Big.version`. Rename *doc* folder to *docs* to use it as the Github publishing source. Add legacy API documentation to *docs*. Add *README* to *perf* directory. Refactor test suite, and add `toNumber` and `prec` tests. Update *README*.
72 lines
1.7 KiB
HTML
72 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang='en'>
|
|
<head>
|
|
<meta charset='utf-8' />
|
|
<title>Testing big.js</title>
|
|
<style> body {font-family: monospace; font-size: 12px; line-height: 14px;}</style>
|
|
<script src='../../big.js'></script>
|
|
<script src='../test.js'></script>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
var arr;
|
|
var head = document.getElementsByTagName("head")[0];
|
|
var color = 'green';
|
|
var passed = 0;
|
|
var total = 0;
|
|
var i = 0;
|
|
var methods = [
|
|
'abs',
|
|
'div',
|
|
'cmp',
|
|
'minus',
|
|
'mod',
|
|
'plus',
|
|
'pow',
|
|
'prec',
|
|
'round',
|
|
'sqrt',
|
|
'times',
|
|
'toExponential',
|
|
'toFixed',
|
|
'toNumber',
|
|
'toPrecision',
|
|
'toString'
|
|
];
|
|
var start = +new Date();
|
|
|
|
function load() {
|
|
var method = methods[i++];
|
|
if (!method) {
|
|
document.body.innerHTML += '<br><div style="display:inline-block;padding:4px;border:4px solid ' + color +
|
|
'">In total, ' + passed + ' of ' + total + ' tests passed in ' + ((+new Date() - start) / 1000) + ' secs.</div>';
|
|
document.body.scrollIntoView(false);
|
|
return;
|
|
}
|
|
|
|
var script = document.createElement("script");
|
|
script.src = '../methods/' + method + '.js';
|
|
script.onload = script.onreadystatechange = function () {
|
|
if (!script.readyState || /loaded|complete/.test(script.readyState)) {
|
|
if (test.result) {
|
|
passed += test.result[0];
|
|
total += test.result[1];
|
|
if (test.result[0] !== test.result[1]) color = 'red';
|
|
} else {
|
|
document.body.innerHTML += '<div style="color:red"> Test script failed - see error console.</div>';
|
|
}
|
|
head.removeChild(script);
|
|
count = script = null;
|
|
document.body.scrollIntoView(false);
|
|
setTimeout(load, 0);
|
|
}
|
|
};
|
|
|
|
head.appendChild(script);
|
|
}
|
|
|
|
document.body.innerHTML += ' Testing big.js<br><br>';
|
|
load();
|
|
</script>
|
|
</body>
|
|
</html> |