MATHCONSTANTS(3clc)

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

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_VALF evaluates to +infinity. it's used as an error value returned by the mathFunctions(3clc). so when a math function is going through it, this is the number it screams at you 😭
  • INFINITY β€” a constant expression of type float representing positive or unsigned infinity. yes bestie, infinity is a real value you can literally just hold in your hand πŸ’–
  • NAN β€” a constant expression of type float representing 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_VAL evaluates to +infinity. used as an error value returned by the built-in math functions. she's the double-precision twin of HUGE_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 e
  • M_LOG2E_F β€” value of logβ‚‚e
  • M_LOG10E_F β€” value of log₁₀e
  • M_LN2_F β€” value of logβ‚‘2
  • M_LN10_F β€” value of logβ‚‘10
  • M_PI_F β€” value of pi πŸ₯§
  • M_PI_2_F β€” value of pi / 2
  • M_PI_4_F β€” value of pi / 4
  • M_1_PI_F β€” value of 1 / pi
  • M_2_PI_F β€” value of 2 / pi
  • M_2_SQRTPI_F β€” value of 2 / (square root of pi)
  • M_SQRT2_F β€” value of square root of 2
  • M_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 e
  • M_LOG2E β€” value of logβ‚‚e
  • M_LOG10E β€” value of log₁₀e
  • M_LN2 β€” value of logβ‚‘2
  • M_LN10 β€” value of logβ‚‘10
  • M_PI β€” value of pi πŸ₯§
  • M_PI_2 β€” value of pi / 2
  • M_PI_4 β€” value of pi / 4
  • M_1_PI β€” value of 1 / pi
  • M_2_PI β€” value of 2 / pi
  • M_2_SQRTPI β€” value of 2 / (square root of pi)
  • M_SQRT2 β€” value of square root of 2
  • M_SQRT1_2 β€” value of 1 / (square root of 2)
heads up bestie: the _F suffix crew is float, the no-suffix crew is double β€” 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β‚‚e
  • M_LOG10E_H β€” Value of log₁₀e
  • M_LN2_H β€” Value of logβ‚‘2
  • M_LN10_H β€” Value of logβ‚‘10
  • M_PI_H β€” Value of pi πŸ₯§
  • M_PI_2_H β€” Value of pi / 2
  • M_PI_4_H β€” Value of pi / 4
  • M_1_PI_H β€” Value of 1 / pi
  • M_2_PI_H β€” Value of 2 / pi
  • M_2_SQRTPI_H β€” Value of 2 / (square root of pi)
  • M_SQRT2_H β€” Value of square root of 2
  • M_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 Β© 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 πŸ“

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