OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/base/ieee754.h" | 7 #include "src/base/ieee754.h" |
8 #include "src/base/macros.h" | 8 #include "src/base/macros.h" |
9 #include "testing/gmock-support.h" | 9 #include "testing/gmock-support.h" |
10 #include "testing/gtest-support.h" | 10 #include "testing/gtest-support.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 EXPECT_EQ(2.3978952727983707, log1p(10)); | 84 EXPECT_EQ(2.3978952727983707, log1p(10)); |
85 EXPECT_EQ(36.841361487904734, log1p(10e15)); | 85 EXPECT_EQ(36.841361487904734, log1p(10e15)); |
86 EXPECT_EQ(37.08337388996168, log1p(12738099905822720)); | 86 EXPECT_EQ(37.08337388996168, log1p(12738099905822720)); |
87 EXPECT_EQ(37.08336444902049, log1p(12737979646738432)); | 87 EXPECT_EQ(37.08336444902049, log1p(12737979646738432)); |
88 EXPECT_EQ(1.3862943611198906, log1p(3)); | 88 EXPECT_EQ(1.3862943611198906, log1p(3)); |
89 EXPECT_EQ(1.3862945995384413, log1p(3 + 9.5367431640625e-7)); | 89 EXPECT_EQ(1.3862945995384413, log1p(3 + 9.5367431640625e-7)); |
90 EXPECT_EQ(0.5596157879354227, log1p(0.75)); | 90 EXPECT_EQ(0.5596157879354227, log1p(0.75)); |
91 EXPECT_EQ(0.8109302162163288, log1p(1.25)); | 91 EXPECT_EQ(0.8109302162163288, log1p(1.25)); |
92 } | 92 } |
93 | 93 |
| 94 TEST(Ieee754, Log2) { |
| 95 EXPECT_THAT(log2(std::numeric_limits<double>::quiet_NaN()), IsNaN()); |
| 96 EXPECT_THAT(log2(std::numeric_limits<double>::signaling_NaN()), IsNaN()); |
| 97 EXPECT_THAT(log2(-std::numeric_limits<double>::infinity()), IsNaN()); |
| 98 EXPECT_THAT(log2(-1.0), IsNaN()); |
| 99 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log2(0.0)); |
| 100 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log2(-0.0)); |
| 101 EXPECT_EQ(std::numeric_limits<double>::infinity(), |
| 102 log2(std::numeric_limits<double>::infinity())); |
| 103 } |
| 104 |
| 105 TEST(Ieee754, Log10) { |
| 106 EXPECT_THAT(log10(std::numeric_limits<double>::quiet_NaN()), IsNaN()); |
| 107 EXPECT_THAT(log10(std::numeric_limits<double>::signaling_NaN()), IsNaN()); |
| 108 EXPECT_THAT(log10(-std::numeric_limits<double>::infinity()), IsNaN()); |
| 109 EXPECT_THAT(log10(-1.0), IsNaN()); |
| 110 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log10(0.0)); |
| 111 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log10(-0.0)); |
| 112 EXPECT_EQ(std::numeric_limits<double>::infinity(), |
| 113 log10(std::numeric_limits<double>::infinity())); |
| 114 EXPECT_EQ(3.0, log10(1000.0)); |
| 115 EXPECT_EQ(14.0, log10(100000000000000)); // log10(10 ^ 14) |
| 116 EXPECT_EQ(3.7389561269540406, log10(5482.2158)); |
| 117 EXPECT_EQ(14.661551142893833, log10(458723662312872.125782332587)); |
| 118 EXPECT_EQ(-0.9083828622192334, log10(0.12348583358871)); |
| 119 } |
| 120 |
94 } // namespace ieee754 | 121 } // namespace ieee754 |
95 } // namespace base | 122 } // namespace base |
96 } // namespace v8 | 123 } // namespace v8 |
OLD | NEW |