OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <cmath> | 6 #include <cmath> |
7 #include <cstdarg> | 7 #include <cstdarg> |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #if V8_TARGET_ARCH_ARM64 | 10 #if V8_TARGET_ARCH_ARM64 |
(...skipping 2487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2498 template <class T, int ebits, int mbits> | 2498 template <class T, int ebits, int mbits> |
2499 static T FPRound(int64_t sign, int64_t exponent, uint64_t mantissa, | 2499 static T FPRound(int64_t sign, int64_t exponent, uint64_t mantissa, |
2500 FPRounding round_mode) { | 2500 FPRounding round_mode) { |
2501 DCHECK((sign == 0) || (sign == 1)); | 2501 DCHECK((sign == 0) || (sign == 1)); |
2502 | 2502 |
2503 // Only the FPTieEven rounding mode is implemented. | 2503 // Only the FPTieEven rounding mode is implemented. |
2504 DCHECK(round_mode == FPTieEven); | 2504 DCHECK(round_mode == FPTieEven); |
2505 USE(round_mode); | 2505 USE(round_mode); |
2506 | 2506 |
2507 // Rounding can promote subnormals to normals, and normals to infinities. For | 2507 // Rounding can promote subnormals to normals, and normals to infinities. For |
2508 // example, a double with exponent 127 (FLT_MAX_EXP) would appear to be | 2508 // example, a double with exponent 127 (std::numeric_limits<float>::max()_EXP) |
Sven Panne
2014/12/19 06:50:16
:-)
| |
2509 // would appear to be | |
2509 // encodable as a float, but rounding based on the low-order mantissa bits | 2510 // encodable as a float, but rounding based on the low-order mantissa bits |
2510 // could make it overflow. With ties-to-even rounding, this value would become | 2511 // could make it overflow. With ties-to-even rounding, this value would become |
2511 // an infinity. | 2512 // an infinity. |
2512 | 2513 |
2513 // ---- Rounding Method ---- | 2514 // ---- Rounding Method ---- |
2514 // | 2515 // |
2515 // The exponent is irrelevant in the rounding operation, so we treat the | 2516 // The exponent is irrelevant in the rounding operation, so we treat the |
2516 // lowest-order bit that will fit into the result ('onebit') as having | 2517 // lowest-order bit that will fit into the result ('onebit') as having |
2517 // the value '1'. Similarly, the highest-order bit that won't fit into | 2518 // the value '1'. Similarly, the highest-order bit that won't fit into |
2518 // the result ('halfbit') has the value '0.5'. The 'point' sits between | 2519 // the result ('halfbit') has the value '0.5'. The 'point' sits between |
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3830 | 3831 |
3831 delete[] format; | 3832 delete[] format; |
3832 } | 3833 } |
3833 | 3834 |
3834 | 3835 |
3835 #endif // USE_SIMULATOR | 3836 #endif // USE_SIMULATOR |
3836 | 3837 |
3837 } } // namespace v8::internal | 3838 } } // namespace v8::internal |
3838 | 3839 |
3839 #endif // V8_TARGET_ARCH_ARM64 | 3840 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |