Skip to content
Tcl Source Code Update of ”branch/c11-functions”
Login

Update of ”branch/c11-functions”

Overview

Artifact ID: c73cb9501b5ced1cc46ef74c1e6502f60c9d50830c9cb1faaabd3c5feb439767
Page Name:branch/c11-functions
Date: 2026-01-01 15:32:52
Original User: dkf
Mimetype:text/x-markdown
Parent: 77784719fca93f98e58358adaa9f97c302a9a9d4e158a81f67eedcbb4ccf2762 (diff)
Next 94724f0d1ff6b0722616b987e3f070a7aa4b1579454a3d30ed357ab7a2c70ca8
Content

C11 Feature: More Mathematical Functions

This branch adds more mathematical functions from the set listed here. (To be TIPped some time.)

The full list

After removing the type-dupes, as Tcl doesn't do those.

Basic operations

Name Description Tcl notes
fabs computes absolute value of a floating-point value (|x|) Existing: abs() function
fmod computes remainder of the floating-point division operation Existing: fmod() function
remainder computes signed remainder of the floating-point division operation This branch
remquo computes signed remainder as well as the three last bits of the division operation
fma computes fused multiply-add operation; (x*y)+z This branch
fmax determines larger of two floating-point values Existing: max() function
fmin determines smaller of two floating-point values Existing: min() function
fdim determines positive difference of two floating-point values (max(0, x-y)) This branch
nan returns a NaN (not-a-number) Existing: direct understanding (usually as an error)

Exponential functions

Name Description Tcl notes
exp computes e raised to the given power (ex) Existing: exp() function
exp2 computes 2 raised to the given power (2x) This branch
expm1 computes e raised to the given power, minus one (ex-1) This branch
log computes natural (base-e) logarithm (ln(x)) Existing: log() function
log10 computes common (base-10) logarithm (log10(x)) Existing: log10() function
log2 computes base-2 logarithm (log2(x)) This branch
log1p computes natural (base-e) logarithm of 1 plus the given number (ln(1+x)) This branch

Power functions

Name Description Tcl notes
pow computes a number raised to the given power (xy) Existing: pow() function and ** operator
sqrt computes square root (√x) Existing: sqrt() function
cbrt computes cube root (3√x) This branch
hypot computes square root of the sum of the squares of two given numbers (√(x2+y2)) Existing: hypot() function

Trigonometric functions

Name Description Tcl notes
sin computes sine (sin(x)) Existing: sin() function
cos computes cosine (cos(x)) Existing: cos() function
tan computes tangent (tan(x)) Existing: tan() function
asin computes arc sine (sin-1(x)) Existing: asin() function
acos computes arc cosine (cos-1(x)) Existing: acos() function
atan computes arc tangent (tan-1(x)) Existing: atan() function
atan2 computes arc tangent, using signs to determine quadrants Existing: atan2() function

Hyperbolic functions

Name Description Tcl notes
sinh computes hyperbolic sine (sinh(x)) Existing: sinh() function
cosh computes hyperbolic cosine (cosh(x)) Existing: cosh() function
tanh computes hyperbolic tangent (tanh(x)) Existing: tanh() function
asinh computes inverse hyperbolic sine (sinh-1(x)) This branch
acosh computes inverse hyperbolic cosine (cosh-1(x)) This branch
atanh computes inverse hyperbolic tangent (tanh-1(x)) This branch

Error and gamma functions

Name Description Tcl notes
erf computes error function This branch
erfc computes complementary error function This branch
tgamma computes gamma function This branch
lgamma computes natural (base-e) logarithm of the gamma function This branch

Nearest integer floating-point operations

Name Description Tcl notes
ceil computes smallest integer not less than the given value Existing: ceil() function
floor computes largest integer not greater than the given value Existing: floor() function
trunc rounds to nearest integer not greater in magnitude than the given value This branch
round rounds to nearest integer, rounding away from zero in halfway cases Existing: round() function
nearbyint rounds to an integer using current rounding mode
rint rounds to an integer using current rounding mode with exception if the result differs

Floating-point manipulation functions

Name Description Tcl notes
frexp breaks a number into significand and a power of 2 This branch
ldexp multiplies a number by 2 raised to a power This branch
modf breaks a number into integer and fractional parts This branch
scalbn computes efficiently a number times FLT_RADIX raised to a power
ilogb extracts exponent of the given number
logb extracts exponent of the given number This branch
nextafter determines next representable floating-point value towards the given value This branch
copysign produces a value with the magnitude of a given value and the sign of another given value This branch

Classification and comparison

Name Description Tcl notes
fpclassify classifies the given floating-point value Existing: fpclassify command
isfinite checks if the given number has finite value Existing: isfinite() function
isinf checks if the given number is infinite Existing: isinf() function
isnan checks if the given number is NaN Existing: isnan() function
isnormal checks if the given number is normal Existing: isnormal() function
signbit checks if the given number is negative
isgreater checks if the first floating-point argument is greater than the second
isgreaterequal checks if the first floating-point argument is greater or equal than the second
isless checks if the first floating-point argument is less than the second
islessequal checks if the first floating-point argument is less or equal than the second
islessgreater checks if the first floating-point argument is less or greater than the second
isunordered checks if two floating-point values are unordered Existing: isunordered() function