REMAINDER(3clc)
π REMAINDER β the OpenCL Manual, bestie edition π
okay so real talk, this is REMAINDER(3clc) from the OpenCL Manual, and it's about to be your new fave little math function. it's giving "quiet overachiever" energy ngl β¨
β¨ NAME β¨
remainder β the floating point remainder function, periodt π
gentype remainder(gentype x, gentype y);
πΈ DESCRIPTION πΈ
so what does it even DO? it computes a value r such that:
r = x - n*y
where n is the integer nearest the exact value of x/y. yes bestie, the nearest one π
and here's the lil plot twist: if there are two integers that are both equally close to x/y, then n shall be the even one. tie goes to the even number, no cap π
also if r is zero, it's given the same sign as x. keeping the vibe consistent fr fr π¦
π NOTES π
okay gather round, this part matters π«Ά
- the vector versions of the math functions operate component-wise. the description is per-component. so like, each lane does its own lil thing π«
- 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 whatever chaos the environment is doing, these functions are unbothered, unbothered, moisturized, in their lane π
- 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. no mixing, bestie π
- the generic type name
gentypeis used to indicate that the function can takefloat,float2,float3,float4,float8,float16,double,double2,double3,double4,double8, ordouble16as the type for the arguments. she contains multitudes β¨ - if extended with
cl_khr_fp16(3clc), the generic type namegentypemay indicatehalfandhalf{2|3|4|8|16}as arguments and return values. glow up unlocked π§ - the generic type name
gentypefis used to indicate that the function can takefloat,float2,float3,float4,float8, orfloat16as the type for the arguments. float girlies only π - the generic type name
gentypedis used to indicate that the function can takedouble,double2,double3,double4,double8, ordouble16as the type for the arguments. double precision divas, this one's for you π
π SPECIFICATION π
OpenCL Specification[1] β yeah, she's official π₯
π SEE ALSO π
mathFunctions(3clc)β go read her next, she's iconic π
π AUTHORS π
The Khronos Group. the main characters fr fr β
Β©οΈ 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 following condition: the above copyright notice and this permission notice shall be included in all copies or substantial portions of the Materials.
bestie that's the legal bit, don't skip it, keep the notice in your copies π
π NOTES π
- OpenCL Specification page 244, section 6.12.2 - Math Functions
and that's the whole page, bestie π this dropped from The Khronos Group on 01/14/2021, and it's still serving. go compute some remainders and slay π β¨π¦
π¦ 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