sincos(3)

✨ sincos(3) β€” the manual page, but make it cute ✨

okay bestie, pull up a chair 🫢 this is sincos, straight out of the Library Functions Manual. she's a libm girlie πŸ’…


πŸŽ€ NAME πŸŽ€

sincos, sincosf, sincosl β€” calculate sin and cos simultaneously. two for the price of one, no cap ✨


πŸ“š LIBRARY πŸ“š

Math library β€” that's libm, and you link her with -lm. don't forget her or she simply will not show up πŸ’€


🌸 SYNOPSIS 🌸

#define _GNU_SOURCE         /* See feature_test_macros(7) */
#include <math.h>

void sincos(double x, double *sin, double *cos);
void sincosf(float x, float *sin, float *cos);
void sincosl(long double x, long double *sin, long double *cos);

πŸ’– DESCRIPTION πŸ’–

so, like β€” a bunch of applications need the sine AND the cosine of the same angle x. and instead of making you do two whole separate trips, these functions compute both at the same time and tuck the results into *sin and *cos. it's giving efficiency, it's giving one-stop shop πŸ›οΈ

using this function can be more efficient than two separate calls to sin(3) and cos(3). lowkey iconic behaviour.

  • if x is a NaN, a NaN is returned in *sin and *cos. NaN in, NaN out, the vibes are consistent πŸ¦‹
  • if x is positive infinity or negative infinity, a domain error occurs, and a NaN is returned in *sin and *cos. like, sorry bestie, infinity is not invited to this party πŸ™ˆ

🌈 RETURN VALUE 🌈

these functions return void. that's it. they return nothing, they just fill in your pointers and vibe. very demure, very mindful πŸŽ€


πŸ”₯ ERRORS πŸ”₯

peep math_error(7) for the whole rundown on how to figure out whether an error actually happened while you were calling these functions πŸ‘€

here's the error that can pop off:

  • Domain error: x is an infinity β€” errno is set to EDOM (but see BUGS below, she's got lore). an invalid floating-point exception (FE_INVALID) is raised. πŸ’€

πŸ‘‘ ATTRIBUTES πŸ‘‘

for what all these terms even mean, check attributes(7). here's the tea:

  • Interface: sincos(), sincosf(), sincosl()
  • Attribute: Thread safety
  • Value: MT-Safe ✨ (yes ma'am, safe to share, we love to see it)

⭐ STANDARDS ⭐

GNU. that's the standard. that's the list. periodt πŸ’…


🧚 HISTORY 🧚

glibc 2.1. she's been around, she's got history, she's a legacy queen πŸ‘‘


πŸ’œ NOTES πŸ’œ

so if you're trying to actually see the performance glow-up of sincos(), it may be necessary to disable gcc(1) built-in optimizations, using flags such as:

cc -O -lm -fno-builtin prog.c

because otherwise gcc is out here doing the optimization on its own and stealing her moment 😭


πŸ’€ BUGS πŸ’€

before glibc 2.22, the glibc implementation did not set errno to EDOM when a domain error occurred. so if you're on old glibc and relying on that, nope, she wasn't doing it. fixed now, but iykyk πŸ™ˆ


🌟 SEE ALSO 🌟


k that's the whole page bestie, go forth and compute both at once πŸ¦‹πŸ’–

this edition is from Linux man-pages 6.20, dated 2026-02-08 β€” mwah, bye πŸŽ€βœ¨

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms