| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 // Extra POSIX/ANSI routines for Win32 when using Visual Studio C++. Please | 5 // Extra POSIX/ANSI routines for Win32 when using Visual Studio C++. Please |
| 6 // refer to The Open Group Base Specification for specification of the correct | 6 // refer to The Open Group Base Specification for specification of the correct |
| 7 // semantics for these functions. | 7 // semantics for these functions. |
| 8 // (http://www.opengroup.org/onlinepubs/000095399/) | 8 // (http://www.opengroup.org/onlinepubs/000095399/) |
| 9 #if defined(_MSC_VER) && (_MSC_VER < 1800) | 9 #if defined(_MSC_VER) && (_MSC_VER < 1800) |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 int flags = _fpclass(x); | 55 int flags = _fpclass(x); |
| 56 | 56 |
| 57 // Determine class. We cannot use a switch statement because | 57 // Determine class. We cannot use a switch statement because |
| 58 // the _FPCLASS_ constants are defined as flags. | 58 // the _FPCLASS_ constants are defined as flags. |
| 59 if (flags & (_FPCLASS_PN | _FPCLASS_NN)) return FP_NORMAL; | 59 if (flags & (_FPCLASS_PN | _FPCLASS_NN)) return FP_NORMAL; |
| 60 if (flags & (_FPCLASS_PZ | _FPCLASS_NZ)) return FP_ZERO; | 60 if (flags & (_FPCLASS_PZ | _FPCLASS_NZ)) return FP_ZERO; |
| 61 if (flags & (_FPCLASS_PD | _FPCLASS_ND)) return FP_SUBNORMAL; | 61 if (flags & (_FPCLASS_PD | _FPCLASS_ND)) return FP_SUBNORMAL; |
| 62 if (flags & (_FPCLASS_PINF | _FPCLASS_NINF)) return FP_INFINITE; | 62 if (flags & (_FPCLASS_PINF | _FPCLASS_NINF)) return FP_INFINITE; |
| 63 | 63 |
| 64 // All cases should be covered by the code above. | 64 // All cases should be covered by the code above. |
| 65 ASSERT(flags & (_FPCLASS_SNAN | _FPCLASS_QNAN)); | 65 DCHECK(flags & (_FPCLASS_SNAN | _FPCLASS_QNAN)); |
| 66 return FP_NAN; | 66 return FP_NAN; |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 // Test sign - usually defined in math.h | 70 // Test sign - usually defined in math.h |
| 71 int signbit(double x) { | 71 int signbit(double x) { |
| 72 // We need to take care of the special case of both positive | 72 // We need to take care of the special case of both positive |
| 73 // and negative versions of zero. | 73 // and negative versions of zero. |
| 74 if (x == 0) | 74 if (x == 0) |
| 75 return _fpclass(x) & _FPCLASS_NZ; | 75 return _fpclass(x) & _FPCLASS_NZ; |
| 76 else | 76 else |
| 77 return x < 0; | 77 return x < 0; |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace std | 80 } // namespace std |
| 81 | 81 |
| 82 #endif // _MSC_VER | 82 #endif // _MSC_VER |
| OLD | NEW |