MATHCONSTANTS(3clc)
SYMBOLIC MATH CONSTANTS π β¨
okay bestie, welcome to the MATHCONSTANTS(3clc) page from the OpenCL manual π«Ά this one is literally just a big ol' gift basket of pre-made numbers that the language hands you so you never have to type 3.14159... yourself like a peasant π
NAME π
Symbolic_Math_Constants β the following symbolic constants are available.
no cap, that's the whole name section. we move. π¦
BUILT-IN MATH CONSTANTS π
the float girlies β¨
so these symbolic constants are available, and their values are of type float β accurate within the precision of a single precision floating-point number. iykyk, don't expect double vibes here π
MAXFLOATβ the value of the maximum non-infinite single-precision floating-point number. like, the biggest number you can have before it stops being a number and becomes β¨conceptβ¨.HUGE_VALFβ a positive float constant expression.HUGE_VALFevaluates to +infinity. it's used as an error value returned by themathFunctions(3clc). so when a math function is going through it, this is the number it screams at you πINFINITYβ a constant expression of typefloatrepresenting positive or unsigned infinity. yes bestie, infinity is a real value you can literally just hold in your hand πNANβ a constant expression of typefloatrepresenting a quiet NaN. she's quiet. she's not a number. she's thriving. π
the double-precision bonus round π
if double precision is supported by the device, this symbolic constant is also available:
HUGE_VALβ a positive double constant expression.HUGE_VALevaluates to +infinity. used as an error value returned by the built-in math functions. she's the double-precision twin ofHUGE_VALF, slay π«Ά
the M_ constants (float edition) π
these constants are also available. they are of type float and are accurate within the precision of the float type. every single one of them is a certified bop:
M_E_Fβ value of eM_LOG2E_Fβ value of logβeM_LOG10E_Fβ value of logββeM_LN2_Fβ value of logβ2M_LN10_Fβ value of logβ10M_PI_Fβ value of pi π₯§M_PI_2_Fβ value of pi / 2M_PI_4_Fβ value of pi / 4M_1_PI_Fβ value of 1 / piM_2_PI_Fβ value of 2 / piM_2_SQRTPI_Fβ value of 2 / (square root of pi)M_SQRT2_Fβ value of square root of 2M_SQRT1_2_Fβ value of 1 / (square root of 2)
the M_ constants (double edition, no _F suffix) π
if double precision is supported by the device, these macros and constants are also available. they are of type double and are accurate within the precision of the double type. same energy, more precision, main character behaviour fr fr:
M_Eβ value of eM_LOG2Eβ value of logβeM_LOG10Eβ value of logββeM_LN2β value of logβ2M_LN10β value of logβ10M_PIβ value of pi π₯§M_PI_2β value of pi / 2M_PI_4β value of pi / 4M_1_PIβ value of 1 / piM_2_PIβ value of 2 / piM_2_SQRTPIβ value of 2 / (square root of pi)M_SQRT2β value of square root of 2M_SQRT1_2β value of 1 / (square root of 2)
heads up bestie: the_Fsuffix crew isfloat, the no-suffix crew isdoubleβ and the double crew only shows up if your device actually supports double precision. vibe check your device first, don't just assume π
we're not done yet β there's more of this page coming, so hold that thought π§π
okay bestie so there's ALSO a whole extra lil squad of constants and they're all type half β meaning they're accurate within the precision of the half type, periodt π
. And real talk: if your app wants to use half and halfn types, you GOTTA include this directive first:
#pragma OPENCL EXTENSION cl_khr_fp16(3clc) : enable
(yes that whole thing including the (3clc) is the name, no cap π«Ά)
here's the entire lineup, absolutely iconic behavior:
M_E_Hβ Value of e β¨M_LOG2E_Hβ Value of logβeM_LOG10E_Hβ Value of logββeM_LN2_Hβ Value of logβ2M_LN10_Hβ Value of logβ10M_PI_Hβ Value of pi π₯§M_PI_2_Hβ Value of pi / 2M_PI_4_Hβ Value of pi / 4M_1_PI_Hβ Value of 1 / piM_2_PI_Hβ Value of 2 / piM_2_SQRTPI_Hβ Value of 2 / (square root of pi)M_SQRT2_Hβ Value of square root of 2M_SQRT1_2_Hβ Value of 1 / (square root of 2)
β¨ SPECIFICATION β¨
OpenCL Specification[1]
π SEE ALSO π
mathFunctions(3clc), FP_CONTRACT(3clc), macroLimits(3clc)
π«Ά 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 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 251, section 6.12.2 - Table at end of Math Functions
and that's the whole page bestie π this lil masterpiece was brought to you by The Khronos Group, dated 01/14/2021, and the footer was lowkey serving SYMBOLIC MATH CONSTA(3clc) energy the entire time β¨π
π¦ 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