FREXP(3clc)
π FREXP(3clc) π
okay bestie, gather round, because we're doing frexp from the OpenCL Manual and honestly? it's giving math but make it fashion β¨
πΈ NAME πΈ
frexp β extract mantissa and exponent, no cap π
π SYNOPSIS π
like, there are eighteen of these and every single one is iconic, so buckle up:
floatn frexp(floatn x, __global intn *exp);
floatn frexp(floatn x, __local intn *exp);
floatn frexp(floatn x, __private intn *exp);
float frexp(float x, __global int *exp);
float frexp(float x, __local int *exp);
float frexp(float x, __private int *exp);
doublen frexp(doublen x, __global intn *exp);
doublen frexp(doublen x, __local intn *exp);
doublen frexp(doublen x, __private intn *exp);
double frexp(double x, __global int *exp);
double frexp(double x, __local int *exp);
double frexp(double x, __private int *exp);
halfn frexp(halfn x, __global intn *exp);
halfn frexp(halfn x, __local intn *exp);
halfn frexp(halfn x, __private intn *exp);
half frexp(half x, __global int *exp);
half frexp(half x, __local int *exp);
half frexp(half x, __private int *exp);
eighteen overloads. eighteen. the range? unmatched. π«Ά
β¨ DESCRIPTION β¨
So what are we doing here? We're pulling the mantissa and the exponent out of x, bestie. That's the whole vibe.
For each component, the mantissa you get back is a float with magnitude sitting pretty in the interval [1/2, 1) β or it's 0, that's also allowed, she contains multitudes π
And the glow-up equation? Every component of x equals the mantissa you got back * 2exp. That's it. That's the math. iconic π
π¦ NOTES π¦
- The built-in math functions are not affected by whatever rounding mode is vibing in the calling environment, and they always return the same value as they would if they'd been called with the round to nearest even rounding mode. periodt. π
- An application that wants to use the
halfandhalfntypes is gonna need to include the#pragma OPENCL EXTENSION cl_khr_fp16(3clc) : enabledirective. no directive, no halfs, that's the rule π
β SPECIFICATION β
OpenCL Specification[1] π
π SEE ALSO π
mathFunctions(3clc)β go say hi to the rest of the family π«Ά
π AUTHORS π
The Khronos Group β the actual main characters, honestly π
πΈ 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. π
π NOTES π
OpenCL Specificationβ page 244, section6.12.2 - Math Functionsβ¨
lowkey a whole saga for one little function, but she earned it π
and that's the tea, bestie π§ this page is from the OpenCL Manual, dated 01/14/2021, brought to you by The Khronos Group β and yes, the name up top was FREXP(3clc) the whole time ππ stay slay, stay floating-point β¨π¦πΈ
π¦ 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