Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: test/cctest/test-diy_fp.cc

Issue 973001: Version 2.1.4.1... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/gay_shortest.h ('k') | test/cctest/test-double.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2
3 #include <stdlib.h>
4
5 #include "v8.h"
6
7 #include "platform.h"
8 #include "cctest.h"
9 #include "diy_fp.h"
10
11
12 using namespace v8::internal;
13
14
15 TEST(Subtract) {
16 DiyFp diy_fp1 = DiyFp(3, 0);
17 DiyFp diy_fp2 = DiyFp(1, 0);
18 DiyFp diff = DiyFp::Minus(diy_fp1, diy_fp2);
19
20 CHECK(2 == diff.f()); // NOLINT
21 CHECK_EQ(0, diff.e());
22 diy_fp1.Subtract(diy_fp2);
23 CHECK(2 == diy_fp1.f()); // NOLINT
24 CHECK_EQ(0, diy_fp1.e());
25 }
26
27
28 TEST(Multiply) {
29 DiyFp diy_fp1 = DiyFp(3, 0);
30 DiyFp diy_fp2 = DiyFp(2, 0);
31 DiyFp product = DiyFp::Times(diy_fp1, diy_fp2);
32
33 CHECK(0 == product.f()); // NOLINT
34 CHECK_EQ(64, product.e());
35 diy_fp1.Multiply(diy_fp2);
36 CHECK(0 == diy_fp1.f()); // NOLINT
37 CHECK_EQ(64, diy_fp1.e());
38
39 diy_fp1 = DiyFp(V8_2PART_UINT64_C(0x80000000, 00000000), 11);
40 diy_fp2 = DiyFp(2, 13);
41 product = DiyFp::Times(diy_fp1, diy_fp2);
42 CHECK(1 == product.f()); // NOLINT
43 CHECK_EQ(11 + 13 + 64, product.e());
44
45 // Test rounding.
46 diy_fp1 = DiyFp(V8_2PART_UINT64_C(0x80000000, 00000001), 11);
47 diy_fp2 = DiyFp(1, 13);
48 product = DiyFp::Times(diy_fp1, diy_fp2);
49 CHECK(1 == product.f()); // NOLINT
50 CHECK_EQ(11 + 13 + 64, product.e());
51
52 diy_fp1 = DiyFp(V8_2PART_UINT64_C(0x7fffffff, ffffffff), 11);
53 diy_fp2 = DiyFp(1, 13);
54 product = DiyFp::Times(diy_fp1, diy_fp2);
55 CHECK(0 == product.f()); // NOLINT
56 CHECK_EQ(11 + 13 + 64, product.e());
57
58 // Halfway cases are allowed to round either way. So don't check for it.
59
60 // Big numbers.
61 diy_fp1 = DiyFp(V8_2PART_UINT64_C(0xFFFFFFFF, FFFFFFFF), 11);
62 diy_fp2 = DiyFp(V8_2PART_UINT64_C(0xFFFFFFFF, FFFFFFFF), 13);
63 // 128bit result: 0xfffffffffffffffe0000000000000001
64 product = DiyFp::Times(diy_fp1, diy_fp2);
65 CHECK(V8_2PART_UINT64_C(0xFFFFFFFF, FFFFFFFe) == product.f());
66 CHECK_EQ(11 + 13 + 64, product.e());
67 }
OLDNEW
« no previous file with comments | « test/cctest/gay_shortest.h ('k') | test/cctest/test-double.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698