| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 if (x > INT_MAX) return INT_MAX; | 65 if (x > INT_MAX) return INT_MAX; |
| 66 return static_cast<int>(x); | 66 return static_cast<int>(x); |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 // The fast double-to-(unsigned-)int conversion routine does not guarantee | 70 // The fast double-to-(unsigned-)int conversion routine does not guarantee |
| 71 // rounding towards zero. | 71 // rounding towards zero. |
| 72 // The result is unspecified if x is infinite or NaN, or if the rounded | 72 // The result is unspecified if x is infinite or NaN, or if the rounded |
| 73 // integer value is outside the range of type int. | 73 // integer value is outside the range of type int. |
| 74 inline int FastD2I(double x) { | 74 inline int FastD2I(double x) { |
| 75 return static_cast<int>(x); | 75 return static_cast<int32_t>(x); |
| 76 } | 76 } |
| 77 | 77 |
| 78 inline unsigned int FastD2UI(double x); | 78 inline unsigned int FastD2UI(double x); |
| 79 | 79 |
| 80 | 80 |
| 81 inline double FastI2D(int x) { | 81 inline double FastI2D(int x) { |
| 82 // There is no rounding involved in converting an integer to a | 82 // There is no rounding involved in converting an integer to a |
| 83 // double, so this code should compile to a few instructions without | 83 // double, so this code should compile to a few instructions without |
| 84 // any FPU pipeline stalls. | 84 // any FPU pipeline stalls. |
| 85 return static_cast<double>(x); | 85 return static_cast<double>(x); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // Additional number to string conversions for the number type. | 149 // Additional number to string conversions for the number type. |
| 150 // The caller is responsible for calling free on the returned pointer. | 150 // The caller is responsible for calling free on the returned pointer. |
| 151 char* DoubleToFixedCString(double value, int f); | 151 char* DoubleToFixedCString(double value, int f); |
| 152 char* DoubleToExponentialCString(double value, int f); | 152 char* DoubleToExponentialCString(double value, int f); |
| 153 char* DoubleToPrecisionCString(double value, int f); | 153 char* DoubleToPrecisionCString(double value, int f); |
| 154 char* DoubleToRadixCString(double value, int radix); | 154 char* DoubleToRadixCString(double value, int radix); |
| 155 | 155 |
| 156 } } // namespace v8::internal | 156 } } // namespace v8::internal |
| 157 | 157 |
| 158 #endif // V8_CONVERSIONS_H_ | 158 #endif // V8_CONVERSIONS_H_ |
| OLD | NEW |