| 1 |
// Copyright 2009 the Sputnik authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
info: | |
| 6 |
If x is equal to 0 or greater than 0, or if x is less than -0.5, |
| 7 |
Math.round(x) is equal to Math.floor(x+0.5) |
| 8 |
es5id: 15.8.2.15_A6 |
| 9 |
description: > |
| 10 |
Checking if Math.round(x) is equal to Math.floor(x+0.5), where x |
| 11 |
equals to 0, greater than 0, or is less than -0.5; this check is |
| 12 |
performed on 2000 argument x values |
| 13 |
---*/ |
| 14 |
|
| 15 |
// CHECK#1 |
| 16 |
for (var i = 0; i <= 1000; i++) |
| 17 |
{ |
| 18 |
var x = i / 10.0; |
| 19 |
if (Math.round(x) !== Math.floor(x + 0.5)) |
| 20 |
{ |
| 21 |
$ERROR("#1: 'x = " + x + "; Math.round(x) !== Math.floor(x + 0.5)'") |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
for (i = -5; i >= -1000; i--) |
| 26 |
{ |
| 27 |
if (i === -5) |
| 28 |
{ |
| 29 |
x = -0.500000000000001; |
| 30 |
} else |
| 31 |
{ |
| 32 |
x = i / 10.0; |
| 33 |
} |
| 34 |
|
| 35 |
if (Math.round(x) !== Math.floor(x + 0.5)) |
| 36 |
{ |
| 37 |
$ERROR("#2: 'x = " + x + "; Math.round(x) !== Math.floor(x + 0.5)'") |
| 38 |
} |
| 39 |
} |