Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8900045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:00:32+00:00 2026-06-15T01:00:32+00:00

This is a really simple question: Why are there predefined constants for pi, pi/2,

  • 0

This is a really simple question: Why are there predefined constants for pi, pi/2, pi/4, 1/pi and 2/pi but not for 2*pi? Is there a deeper reason behind it?

This question is not about the whole pi vs tau debate. I am wondering if there is a technical reason for implementing certain constants but not others. I can think of two possibilities:

  1. Avoiding rounding errors.
  2. Avoiding runtime divisions which might be more expensive.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:00:34+00:00Added an answer on June 15, 2026 at 1:00 am

    This is just my guess.

    I suppose that these constants are related to the implementations of different functions in the math library:

    ck@c:~/Codes/ref/glibc/math$ grep PI *.c
    s_cacos.c:  __real__ res = (double) M_PI_2 - __real__ y;
    s_cacosf.c:  __real__ res = (float) M_PI_2 - __real__ y;
    s_cacosh.c:                    ? M_PI - M_PI_4 : M_PI_4)
    ...
    s_clogf.c:      __imag__ result = signbit (__real__ x) ? M_PI : 0.0;
    s_clogl.c:      __imag__ result = signbit (__real__ x) ? M_PIl : 0.0;
    ck@c:~/Codes/ref/glibc/math$ 
    

    M_PI, M_PI_2, and M_PI_4 show up quite often but there’s no 2.0 * M_PI. So to Hanno’s original question, I think MvanGeest is right — 2π is just not that useful, at least in implementing libm.

    Now about M_PI_2 and M_PI_4, their existences are well justified. The documentation of the GNU C library suggests that “these constants come from the Unix98 standard and were also available in 4.4BSD”. Compilers were not that smart back at that time. Typing M_PI/4 instead of M_PI_4 may cause an unnecessary division. Although modern compilers can optimize that away (gcc uses mpfr since 2008 so even rounding is done correctly), using numeric constants is still a more portable way to write high performance code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There might be a really simple solution to this question, but i just don't
I know there must be a really simple answer to this question, but I
This might be a pretty simple question, but if there really is a difference,
This should be really really simple, but for whatever reason... String line; String question
This is a really simple question, but I can't seem to find the answer.
I know this is a really simple question but my google-fu is failing me.
This sounds like a really simple question, but I am new to PHP. If
This is probably a really simple question but one I've never quite worked out
This is a simple question really (but I couldn't seem to find the answer
This may be a really simple question, but I'm trying to create the database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.