Update float value tests

This commit is contained in:
Bill Ticehurst 2012-08-08 15:16:36 -07:00
parent 385b4f7163
commit 19634b74f6
7 changed files with 81 additions and 38 deletions

View File

@ -0,0 +1,64 @@
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
* @path ch08/8.5/8.5.1.js
* @description Valid Number ranges
*/
// Check range support for Number values (IEEE 754 64-bit floats having the form s*m*2**e)
//
// For normalized floats, sign (s) is +1 or -1, m (mantisa) is a positive integer less
// than 2**53 but not less than 2**52 and e (exponent) is an integer ranging from -1074 to 971
//
// For denormalized floats, s is +1 or -1, m is a positive integer less than 2**52, and
// e is -1074
//
// Below 64-bit float values shown for informational purposes. Values may be positive or negative.
// Infinity >= ~1.797693134862315907729305190789e+308 >= 2**1024
// MAX_NORM = ~1.797693134862315708145274237317e+308 = (2**53 - 1) * (2**-52) * (2**1023) = (2**53-1) * (2**971) = (2**1024) - (2**971)
// MIN_NORM = ~2.2250738585072013830902327173324e-308 = 2**-1022
// MAX_DENORM = ~2.2250738585072008890245868760859e-308 = MIN_NORM - MIN_DENORM = (2**-1022) - (2**-1074)
// MIN_DENORM = ~4.9406564584124654417656879286822e-324 = 2**-1074
// Fill an array with 2 to the power of (0 ... -1075)
var value = 1;
var floatValues = new Array(1076);
for(var power = 0; power <= 1075; power++){
floatValues[power] = value;
// Use basic math operations for testing, which are required to support 'gradual underflow' rather
// than Math.pow etc..., which are defined as 'implementation dependent'.
value = value * 0.5;
}
// The last value is below min denorm and should round to 0, everything else should contain a value
if(floatValues[1075] !== 0) {
$ERROR("Value after min denorm should round to 0");
}
// Validate the last actual value is min denorm
if(floatValues[1074] !== 4.9406564584124654417656879286822e-324) {
$ERROR("Min denorm value is incorrect: " + floatValues[1074]);
}
// Validate that every value is half the value before it up to 1
for(var index = 1074; index > 0; index--){
if(floatValues[index] === 0){
$ERROR("2**-" + index + " should not be 0");
}
if(floatValues[index - 1] !== (floatValues[index] * 2)){
$ERROR("Value should be double adjacent value at index " + index);
}
}
// Max norm should be supported and compare less than inifity
if(!(1.797693134862315708145274237317e+308 < Infinity)){
$ERROR("Max Number value 1.797693134862315708145274237317e+308 should not overflow to infinity");
}
// Numbers closer to 2**1024 then max norm should overflow to infinity
if(!(1.797693134862315808e+308 === +Infinity)){
$ERROR("1.797693134862315808e+308 did not resolve to Infinity");
}

View File

@ -1,28 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* Finite nonzero values that are Normalised having the form s*m*2**e
* where s is +1 or -1, m is a positive integer less than 2**53 but not
* less than s**52 and e is an integer ranging from -1074 to 971
*
* @path ch08/8.5/S8.5_A13_T1.js
* @description Finite Non zero values where e is -1074
* @implDependent Does not pass on current ARM processors
*/
//CHECK #1
if ((1*((Math.pow(2,53))-1)*(Math.pow(2,-1074))) !== 4.4501477170144023e-308){
$ERROR('#1: (1*((Math.pow(2,53))-1)*(Math.pow(2,-1074))) === 4.4501477170144023e-308. Actual: ' + ((1*((Math.pow(2,53))-1)*(Math.pow(2,-1074)))));
}
//CHECK #2
if ((1*(Math.pow(2,52))*(Math.pow(2,-1074))) !== 2.2250738585072014e-308){
$ERROR('#2: (1*(Math.pow(2,52))*(Math.pow(2,-1074))) === 2.2250738585072014e-308. Actual: ' + ((1*(Math.pow(2,52))*(Math.pow(2,-1074)))));
}
//CHECK #3
if ((-1*(Math.pow(2,52))*(Math.pow(2,-1074))) !== -2.2250738585072014e-308){
$ERROR('#3: (-1*(Math.pow(2,52))*(Math.pow(2,-1074))) === -2.2250738585072014e-308. Actual: ' + ((-1*(Math.pow(2,52))*(Math.pow(2,-1074)))));
}

View File

@ -77,7 +77,11 @@ x[59] = 5.88425290672373970000;
x[60] = 5.98398600683770090000;
x[61] = 6.08371910695166300000;
x[62] = 6.18345220706562420000;
x[63] = 6.28318530717958620000;
// Result is implementation dependent and varies on platform as you approach limits.
// e.g. Output approaches zero as input approaches PI * 2 (6.28318530717958647).
// The value of 6.2831 for x[63] is chosen below as an arbitrary cut off point for
// expecting a result within the validation's tolerance range.
x[63] = 6.2831;
var y = new Array();
@ -144,8 +148,7 @@ y[59] = -0.38843479627469474000;
y[60] = -0.29475517441090471000;
y[61] = -0.19814614319939772000;
y[62] = -0.09956784659581728600;
y[63] = -0.0000000000000002449293598294706400;
y[63] = -0.00008530717948287973;
var val;
for (i = 0; i < vnum; i++)

View File

@ -14,7 +14,11 @@ $INCLUDE("math_isequal.js");
// CHECK#1
vnum = 64;
var x = new Array();
x[0] = -1.57079632679489660000;
// Result is implementation dependent and varies on platform as you approach limits.
// e.g. Output approaches Infinity as input approaches PI / 2 (1.5707963267948966)
// The value of 1.5707 for x[0] is chosen below as an arbitrary cut off point for
// expecting a result within the validation's tolerance range.
x[0] = -1.5707;
x[1] = -1.52092977673791570000;
x[2] = -1.47106322668093490000;
x[3] = -1.42119667662395410000;
@ -77,12 +81,12 @@ x[59] = 1.37133012656697330000;
x[60] = 1.42119667662395390000;
x[61] = 1.47106322668093490000;
x[62] = 1.52092977673791550000;
x[63] = 1.57079632679489660000;
x[63] = 1.5707;
var y = new Array();
y[0] = -16331239353195370.00000000000000000000;
y[0] = -10381.32741756979;
y[1] = -20.03689788997828100000;
y[2] = -9.99349498241742220000;
y[3] = -6.63456649978931170000;
@ -145,7 +149,7 @@ y[59] = 4.94671494494940060000;
y[60] = 6.63456649978930190000;
y[61] = 9.99349498241742220000;
y[62] = 20.03689788997819200000;
y[63] = 16331239353195370.00000000000000000000;
y[63] = 10381.32741756979;
var val;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"date":"2012-05-18","version":"ES5.1"}
{"date":"2012-08-08","version":"ES5.1"}