William Kahan: Warum ist dezimale Gleitkomma-Hardware auf jeden Fall eine gute Idee? Weil sie unserer Industrie hilft die Fehler zu vermeiden, die verfahrensbedingt nicht gefunden werden können.
<script> var a = [ ]; a.push('Number.NEGATIVE_INFINITY =' + Number.NEGATIVE_INFINITY); a.push('Number.POSITIVE_INFINITY =' + Number.POSITIVE_INFINITY); a.push('Number.MIN_VALUE =' + Number.MIN_VALUE); a.push('Number.MAX_VALUE =' + Number.MAX_VALUE); alert(a.join('\n') ); </script>
Number.NEGATIVE_INFINITY =-Infinity Number.POSITIVE_INFINITY = Infinity Number.MIN_VALUE = 5e-324 Number.MAX_VALUE = 1.7976931348623157e+308
<script> var k, a = [ ], o = { 'Number.NEGATIVE_INFINITY': Number.NEGATIVE_INFINITY, 'Number.POSITIVE_INFINITY': Number.POSITIVE_INFINITY, 'Number.MIN_VALUE': Number.MIN_VALUE, 'Number.MAX_VALUE': Number.MAX_VALUE, 'Number.MIN_VALUE.toString(2)': Number.MIN_VALUE.toString(2), 'Number.MAX_VALUE.toString(2)': Number.MAX_VALUE.toString(2), 'Number.NEGATIVE_INFINITY': Number.NEGATIVE_INFINITY, 'Number.POSITIVE_INFINITY': Number.POSITIVE_INFINITY, 'Number.MIN_VALUE': Number.MIN_VALUE, 'Number.MAX_VALUE': Number.MAX_VALUE, 'Number.MIN_VALUE.toString(2)': Number.MIN_VALUE.toString(2), 'Number.MAX_VALUE.toString(2)': Number.MAX_VALUE.toString(2) } for (k in o) { if (o.hasOwnProperty(k)) { a.push(k+"="+o[k]);} } alert(a.join('\n')); </script>
-Infinity Infinity 5e-324 1.7976931348623157e+308 NaN NaN
Number.NEGATIVE_INFINITY=-Infinity Number.POSITIVE_INFINITY=Infinity Number.MIN_VALUE=5e-324 Number.MAX_VALUE=1.7976931348623157e+308 Number.MIN_VALUE.toString(2)= 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 Number.MAX_VALUE.toString(2)= 0111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
alert( o["NaN" ] + ' ' + o["null"] + ' ' + o["undefined"] + ' '+ o["-0" ] + ' ' + o["+0" ] + ' ' + o["''" ] + ' ' + o["{ }" ] );
var o = { "NaN": Boolean( NaN ), "null": Boolean( null ), "undefined": Boolean( undefined ), "-0": Boolean( -0 ), "+0": Boolean( +0 ), "''": Boolean( '' ), "{ }": Boolean( { } ) };
var o = { b0 : Infinity === 1/0, b1 : Infinity === Number.POSITIVE_INFINITY, b2 : Infinity === 1.79778e+308, b3 : Infinity === Number.MAX_VALUE * 2, b4 : Infinity === Number.MIN_VALUE * -2 };
<script> var equal = (function () { var EPSILON = Math.pow(2, -53); return function (x, y) { return Math.abs(x - y) < EPSILON; }; }()); var x1 = 0.1 + 0.2 , x2 = 0.5 - 0.2 ; </script>
<script> var formatNum = function(format){ return format === 'dec2' ? this.toPrecision(String(this).length+2) : format === 'div10' ? Number(this/10).toPrecision(2) : this; } Number.prototype.format = formatNum; var num = 22; </script>
<script> var obj = { a: 'A', 'd': '64', add: function(x, y) { var r = x + y; return r; }, s:'', x: 12 }; var v1 = obj.add(4,40); var v2 = window.parseInt(obj.d, 16); var v3 = v1 + v2; var v4 = obj.add(v3/obj.x,obj.add(-2,-6)); document.write('v1='+v1+ '<br \/>v2='+v2+ '<br \/>v3='+v3+ '<br \/>v4='+v4 ); </script>
<script> var add = function (x, y) { var r = x + y; return r; }; /*1*/ function mul (x, y) { var r = x * y; return r; } /*2*/ var myobj = { }; /*3*/ myobj.add = add; myobj.mul = mul; var obj = { add: function(x, y) { var r = x + y; return r; }, /*4*/ sub: function(x, y) { var r = x - y; return r; } }; var /*5*/ wert2 = add(1,1), wert6 = myobj.add(3,3), wert8 = obj.add(4,4); var sum_num = wert2 + wert6 + wert8; /*6*/ var sum_string = " " + wert2 + wert6 + wert8; document.write(sum_num + sum_string); </script>
<script> var obj = { add1: function(num) { this.x += num; this.arr.push(this.x); return this; }, add2: function(num) { obj.x += num; obj.arr.push(obj.x); return obj; }, add3: function(num) { try { x += num; } catch(e) { this.arr.push(e); } return obj; }, x: 4711, arr:[ ] }; obj.add1(-4700).add2(-2).add3(-2); document.write( obj.arr.join('<br />') ); </script>
11 9 ReferenceError: Undefined variable: x