Handle NaN value storing in Uint8Clamped typed arrays.
TEST=mjsunit/external-array BUG= R=dslomov@chromium.org Review URL: https://codereview.chromium.org/667113002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24766 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
ac8b70cf2b
commit
0ffa82c3ac
@ -4173,7 +4173,8 @@ typename Traits::ElementType FixedTypedArray<Traits>::from_double(
|
||||
|
||||
template<> inline
|
||||
uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from_double(double value) {
|
||||
if (value < 0) return 0;
|
||||
// Handle NaNs and less than zero values which clamp to zero.
|
||||
if (!(value > 0)) return 0;
|
||||
if (value > 0xFF) return 0xFF;
|
||||
return static_cast<uint8_t>(lrint(value));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user