1
0
Fork 0
cl-sites/novaspec.org/cl/v_pi.html
2025-02-05 18:52:26 +01:00

181 lines
No EOL
4 KiB
HTML

<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>pi | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="v_pi.html"
><LINK REL="next" HREF="f_sinh.html" TYPE="text/html" TITLE="sinh, cosh, tanh, asinh, acosh, atanh"
><LINK REL="prev" HREF="f_asin.html" TYPE="text/html" TITLE="asin, acos, atan"
><LINK REL="up" HREF="12_2_Numbers_Dictionary.html" TYPE="text/html" TITLE="12.2 Numbers Dictionary"
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
><SCRIPT SRC="dpans.js%3F3909942064"
></SCRIPT
><SCRIPT SRC="apropos.js%3F3909942064"
></SCRIPT
></HEAD
><BODY
><DIV
><DIV CLASS="topnav"
><DIV CLASS="breadcrumb"
><SPAN CLASS="breadcrumb-item"
><A HREF="index.html"
>Common Lisp Nova Spec</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="12_Numbers.html"
>12. Numbers</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="12_2_Numbers_Dictionary.html"
>12.2 Numbers Dictionary</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="v_pi.html"
>pi</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="f_asin.html" CLASS="prev"
>&#8592;</A
><SPAN ID="apropos-label"
>Apropos </SPAN
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
><A HREF="f_sinh.html" CLASS="next"
>&#8594;</A
></DIV
><DIV ID="apropos-res"
></DIV
></DIV
></DIV
><DIV CLASS="matter"
><DIV CLASS="com"
><DIV CLASS="begincom"
><HR
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="pi"
></SPAN
><B
>pi</B
></TD
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
><I
>Constant</I
> <I
>Variable</I
></TD
></TR
></TABLE
><HR
></DIV
><UL CLASS="subtoc"
></UL
><DL
><DT
><B
>Value</B
></DT
><DD
><P CLASS="j"
>an <A HREF="26_1_Glossary.html#implementation-dependent"
><EM CLASS="term"
>implementation-dependent</EM
></A
> <A HREF="26_1_Glossary.html#long_float"
><EM CLASS="term"
>long float</EM
></A
>.</P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
>The best <A HREF="26_1_Glossary.html#long_float"
><EM CLASS="term"
>long float</EM
></A
> approximation to the mathematical constant &#960;.</P
></DD
><DT
><B
>Examples</B
></DT
><DD
><PRE CLASS="screen"
>;; In each of the following computations, the precision depends
;; on the implementation. Also, if `long float' is treated by
;; the implementation as equivalent to some other float format
;; (e.g., `double float') the exponent marker might be the marker
;; for that equivalent (e.g., `D' instead of `L').
pi <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> 3.141592653589793L0
(cos pi) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> -1.0L0
(defun sin-of-degrees (degrees)
(let ((x (if (floatp degrees) degrees (float degrees pi))))
(sin (* x (/ (float pi x) 180)))))</PRE
></DD
><DT
><B
>Notes</B
></DT
><DD
><P CLASS="j"
>An approximation to &#960; in some other precision can be obtained by writing <CODE CLASS="f"
>(float pi x)</CODE
>, where <CODE CLASS="f"
>x</CODE
> is a <A HREF="26_1_Glossary.html#float"
><EM CLASS="term"
>float</EM
></A
> of the desired precision, or by writing <CODE CLASS="f"
>(coerce pi <I CLASS="i"
><I
>type</I
></I
>)</CODE
>, where <I CLASS="i"
><I
>type</I
></I
> is the desired type, such as <A HREF="t_short-float.html" CLASS="typeref"
><B
>short-float</B
></A
>.</P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="f_asin.html" CLASS="prev"
>&#8592;</A
><A HREF="f_sinh.html" CLASS="next"
>&#8594;</A
></DIV
><DIV CLASS="trail"
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
></DIV
></DIV
><SCRIPT
>domReady();</SCRIPT
></BODY
></HTML
>