Changeset 27095 in webkit for trunk/JavaScriptCore/kjs/value.cpp
- Timestamp:
- Oct 26, 2007, 12:51:25 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/value.cpp
r26912 r27095 62 62 if (getTruncatedInt32(i)) 63 63 return i; 64 return roundValue(exec, const_cast<JSValue*>(this)); 64 double d = toNumber(exec); 65 return isNaN(d) ? 0.0 : trunc(d); 66 } 67 68 double JSValue::toIntegerPreserveNaN(ExecState *exec) const 69 { 70 int32_t i; 71 if (getTruncatedInt32(i)) 72 return i; 73 return trunc(toNumber(exec)); 65 74 } 66 75 … … 69 78 ok = true; 70 79 71 double d = roundValue(exec, const_cast<JSValue*>(this));80 double d = toNumber(exec); 72 81 if (d >= -D32 / 2 && d < D32 / 2) 73 82 return static_cast<int32_t>(d); … … 77 86 return 0; 78 87 } 79 double d32 = fmod(d, D32);80 88 89 double d32 = fmod(trunc(d), D32); 81 90 if (d32 >= D32 / 2) 82 91 d32 -= D32; 83 92 else if (d32 < -D32 / 2) 84 93 d32 += D32; 85 86 94 return static_cast<int32_t>(d32); 87 95 } … … 91 99 ok = true; 92 100 93 double d = roundValue(exec, const_cast<JSValue*>(this));101 double d = toNumber(exec); 94 102 if (d >= 0.0 && d < D32) 95 103 return static_cast<uint32_t>(d); … … 99 107 return 0; 100 108 } 101 double d32 = fmod(d, D32);102 109 110 double d32 = fmod(trunc(d), D32); 103 111 if (d32 < 0) 104 112 d32 += D32; 105 106 113 return static_cast<uint32_t>(d32); 107 }108 109 uint16_t JSValue::toUInt16(ExecState *exec) const110 {111 uint32_t i;112 if (getTruncatedUInt32(i))113 return static_cast<uint16_t>(i);114 115 double d = roundValue(exec, const_cast<JSValue*>(this));116 if (d >= 0.0 && d < D16)117 return static_cast<uint16_t>(d);118 119 if (isNaN(d) || isInf(d))120 return 0;121 double d16 = fmod(d, D16);122 123 if (d16 < 0)124 d16 += D16;125 126 return static_cast<uint16_t>(d16);127 114 } 128 115
Note:
See TracChangeset
for help on using the changeset viewer.