Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 inline double SignedZero(bool negative) { | 55 inline double SignedZero(bool negative) { |
| 56 return negative ? -0.0 : 0.0; | 56 return negative ? -0.0 : 0.0; |
| 57 } | 57 } |
| 58 | 58 |
| 59 | 59 |
| 60 // The fast double-to-(unsigned-)int conversion routine does not guarantee | 60 // The fast double-to-(unsigned-)int conversion routine does not guarantee |
| 61 // rounding towards zero. | 61 // rounding towards zero. |
| 62 // The result is unspecified if x is infinite or NaN, or if the rounded | 62 // The result is unspecified if x is infinite or NaN, or if the rounded |
|
Sven Panne
2012/07/30 06:21:46
The comment should be synced with the code below.
| |
| 63 // integer value is outside the range of type int. | 63 // integer value is outside the range of type int. |
| 64 inline int FastD2I(double x) { | 64 inline int FastD2I(double x) { |
| 65 // The static_cast convertion from double to int used to be slow, but | 65 // The static_cast convertion from double to int used to be slow, but |
|
Sven Panne
2012/07/30 06:21:46
I think this comment can be removed, it is totally
| |
| 66 // as new benchmarks show, now it is much faster than lrint(). | 66 // as new benchmarks show, now it is much faster than lrint(). |
| 67 if (!(x >= INT_MIN)) return INT_MIN; // Negation to catch NaNs. | |
| 68 if (x > INT_MAX) return INT_MAX; | |
| 67 return static_cast<int>(x); | 69 return static_cast<int>(x); |
| 68 } | 70 } |
| 69 | 71 |
| 70 inline unsigned int FastD2UI(double x); | 72 inline unsigned int FastD2UI(double x); |
| 71 | 73 |
| 72 | 74 |
| 73 inline double FastI2D(int x) { | 75 inline double FastI2D(int x) { |
| 74 // There is no rounding involved in converting an integer to a | 76 // There is no rounding involved in converting an integer to a |
| 75 // double, so this code should compile to a few instructions without | 77 // double, so this code should compile to a few instructions without |
| 76 // any FPU pipeline stalls. | 78 // any FPU pipeline stalls. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 // Additional number to string conversions for the number type. | 141 // Additional number to string conversions for the number type. |
| 140 // The caller is responsible for calling free on the returned pointer. | 142 // The caller is responsible for calling free on the returned pointer. |
| 141 char* DoubleToFixedCString(double value, int f); | 143 char* DoubleToFixedCString(double value, int f); |
| 142 char* DoubleToExponentialCString(double value, int f); | 144 char* DoubleToExponentialCString(double value, int f); |
| 143 char* DoubleToPrecisionCString(double value, int f); | 145 char* DoubleToPrecisionCString(double value, int f); |
| 144 char* DoubleToRadixCString(double value, int radix); | 146 char* DoubleToRadixCString(double value, int radix); |
| 145 | 147 |
| 146 } } // namespace v8::internal | 148 } } // namespace v8::internal |
| 147 | 149 |
| 148 #endif // V8_CONVERSIONS_H_ | 150 #endif // V8_CONVERSIONS_H_ |
| OLD | NEW |