MODF(3clc)
π MODF π
okay bestie, we're cracking open the OpenCL Manual page for modf(3clc) and honestly? it's giving "quietly does the most important thing in the room" energy. let's get into it π«Ά
β¨ NAME β¨
modf β decompose a floating-point number π
gentype modf(gentype x, __global gentype *iptr);
gentype modf(gentype x, __local gentype *iptr);
gentype modf(gentype x, __private gentype *iptr);
πΈ DESCRIPTION πΈ
so modf decomposes a floating-point number. the way it works is it breaks the argument x into an integral part and a fractional part β and here's the cute part β each of them has the same sign as the argument. it stores the integral part in the object pointed to by iptr. slay. β¨
π¦ NOTES π¦
modf behaves as though it were implemented like this:
gentype modf ( gentype value, gentype *iptr )
{
*iptr = trunc(3clc)( value );
return copysign(3clc)( isinf(3clc)( value ) ? 0.0 : value - *iptr, value );
}
not me showing you the whole implementation, iykyk π
the vector versions of the math functions operate component-wise. the description is per-component, bestie.
the built-in math functions are not affected by the prevailing rounding mode in the calling environment, and they always return the same value as they would if called with the round to nearest even rounding mode. so like, don't stress about your environment's rounding drama, she does not care. π
the built-in math functions take scalar or vector arguments. for any specific use of these functions, the actual type has to be the same for all arguments and the return type unless otherwise specified.
the generic type name gentype is used to indicate that the function can take float, float2, float3, float4, float8, float16, double, double2, double3, double4, double8, or double16 as the type for the arguments. that's the whole roster, no cap. π
if extended with cl_khr_fp16(3clc), generic type name gentype may indicate half and half{2|3|4|8|16} as arguments and return values. β¨
the generic type name gentypef is used to indicate that the function can take float, float2, float3, float4, float8, or float16 as the type for the arguments.
the generic type name gentyped is used to indicate that the function can take double, double2, double3, double4, double8, or double16 as the type for the arguments.
β SPECIFICATION β
OpenCL Specification[1]
π SEE ALSO π
π AUTHORS π
The Khronos Group
π COPYRIGHT π
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
π NOTES π
OpenCL Specificationpage 244, section 6.12.2 - Math Functions
okay that's the whole page, you ate that fr fr π«Ά this was brought to you by The Khronos Group, dated 01/14/2021, filed under MODF(3clc) β periodt π β¨
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms