/* * Copyright 2014 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkHalf_DEFINED #define SkHalf_DEFINED #include <cstdint> // 16-bit floating point value // format is 1 bit sign, 5 bits exponent, 10 bits mantissa // only used for storage SkHalf; static constexpr uint16_t SK_HalfNaN = …; // a NaN value, not all possible NaN values static constexpr uint16_t SK_HalfInfinity = …; static constexpr uint16_t SK_HalfMin = …; // 2^-14 (minimum positive normal value) static constexpr uint16_t SK_HalfMax = …; // 65504 (maximum positive normal value) static constexpr uint16_t SK_HalfEpsilon = …; // 2^-10 static constexpr uint16_t SK_Half1 = …; // 1 // Convert between half and single precision floating point. Vectorized functions // skvx::from_half and skvx::to_half are also available. Unlike skvx::to_half, this will // correctly handle float NaN -> half NaN. float SkHalfToFloat(SkHalf h); SkHalf SkFloatToHalf(float f); #endif