REMAINDER(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

πŸ’– 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 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. she contains multitudes ✨
  • if extended with cl_khr_fp16(3clc), the generic type name gentype may indicate half and half{2|3|4|8|16} as arguments and return values. glow up unlocked 🧚
  • 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. float girlies only πŸ’–
  • 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. double precision divas, this one's for you πŸ’œ

πŸ“œ SPECIFICATION πŸ“œ

OpenCL Specification[1] β€” yeah, she's official πŸ”₯

πŸ‘€ SEE ALSO πŸ‘€

πŸ‘‘ AUTHORS πŸ‘‘

The Khronos Group. the main characters fr fr ⭐

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 πŸ“

  1. 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