Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
test262
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pmaksimo
test262
Commits
5d39cad7
Commit
5d39cad7
authored
6 years ago
by
Timothy Gu
Committed by
Leo Balter
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for roundTiesToEven rounding in Math.fround (#2021)
parent
5eab5182
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/built-ins/Math/fround/ties.js
+50
-0
50 additions, 0 deletions
test/built-ins/Math/fround/ties.js
with
50 additions
and
0 deletions
test/built-ins/Math/fround/ties.js
0 → 100644
+
50
−
0
View file @
5d39cad7
// Copyright (C) 2019 Tiancheng "Timothy" Gu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-math.fround
description: Math.fround should use roundTiesToEven for conversion to binary32.
---*/
// We test five values against Math.fround, with their binary64 representation
// shown:
// a0 := 1.0 = 0x1p+0
// a1 := 1.0000000596046448 = 0x1.000001p+0
// a2 := 1.0000001192092896 = 0x1.000002p+0
// a3 := 1.0000001788139343 = 0x1.000003p+0
// a4 := 1.000000238418579 = 0x1.000004p+0
// a5 := 1.0000002980232239 = 0x1.000005p+0
// a6 := 1.0000003576278687 = 0x1.000006p+0
// (Note: they are separated by 2 ** -24.)
//
// a0, a2, a4, and a6 are all representable exactly in binary32; however, while
// a0 and a4 have even mantissas in binary32, a2 and a6 have an odd mantissa
// when represented in that way.
//
// a1 is exactly halfway between a0 and a2, a3 between a2 and a4, and a5
// between a4 and a6. By roundTiesToEven, Math.fround should favor a0 and a4
// over a2 when they are equally close, and a4 over a6 when they are equally
// close.
var
a0
=
1.0
;
var
a1
=
1.0000000596046448
;
var
a2
=
1.0000001192092896
;
var
a3
=
1.0000001788139343
;
var
a4
=
1.000000238418579
;
var
a5
=
1.0000002980232239
;
var
a6
=
1.0000003576278687
;
assert
.
sameValue
(
Math
.
fround
(
a0
),
a0
,
'
Math.fround(a0)
'
);
assert
.
sameValue
(
Math
.
fround
(
a1
),
a0
,
'
Math.fround(a1)
'
);
assert
.
sameValue
(
Math
.
fround
(
a2
),
a2
,
'
Math.fround(a2)
'
);
assert
.
sameValue
(
Math
.
fround
(
a3
),
a4
,
'
Math.fround(a3)
'
);
assert
.
sameValue
(
Math
.
fround
(
a4
),
a4
,
'
Math.fround(a4)
'
);
assert
.
sameValue
(
Math
.
fround
(
a5
),
a4
,
'
Math.fround(a5)
'
);
assert
.
sameValue
(
Math
.
fround
(
a6
),
a6
,
'
Math.fround(a6)
'
);
assert
.
sameValue
(
Math
.
fround
(
-
a0
),
-
a0
,
'
Math.fround(-a0)
'
);
assert
.
sameValue
(
Math
.
fround
(
-
a1
),
-
a0
,
'
Math.fround(-a1)
'
);
assert
.
sameValue
(
Math
.
fround
(
-
a2
),
-
a2
,
'
Math.fround(-a2)
'
);
assert
.
sameValue
(
Math
.
fround
(
-
a3
),
-
a4
,
'
Math.fround(-a3)
'
);
assert
.
sameValue
(
Math
.
fround
(
-
a4
),
-
a4
,
'
Math.fround(-a4)
'
);
assert
.
sameValue
(
Math
.
fround
(
-
a5
),
-
a4
,
'
Math.fround(-a5)
'
);
assert
.
sameValue
(
Math
.
fround
(
-
a6
),
-
a6
,
'
Math.fround(-a6)
'
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment