36 lines
5.4 KiB
HTML
36 lines
5.4 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Section 22.3.3.4</TITLE>
|
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
|
<LINK REL=TOP HREF="../Front/index.htm">
|
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
|
<LINK REL=PREV HREF="22_ccc.htm">
|
|
<LINK REL=UP HREF="22_cc.htm">
|
|
<LINK REL=NEXT HREF="22_cd.htm">
|
|
</HEAD>
|
|
<BODY>
|
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="22_ccc.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="22_cc.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="22_cd.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<H2>
|
|
22.3.3.4 Tilde Dollarsign: Monetary Floating-Point</H2> <P>
|
|
The next <I>arg</I> is printed as a <A REL=DEFINITION HREF="26_glo_f.htm#float"><I>float</I></A> in fixed-format notation. <P>
|
|
The full form is <TT>~</TT><I>d</I><TT>,</TT><I>n</I><TT>,</TT><I>w</I><TT>,</TT><I>padchar</I><TT>$</TT>. The parameter <I>d</I> is the number of digits to print after the decimal point (default value 2); <I>n</I> is the minimum number of digits to print before the decimal point (default value 1); <I>w</I> is the minimum total width of the field to be printed (default value 0). <P>
|
|
First padding and the sign are output. If the <I>arg</I> is negative, then a minus sign is printed; if the <I>arg</I> is not negative, then a plus sign is printed if and only if the <TT>@</TT> modifier was supplied. If the <TT>:</TT> modifier is used, the sign appears before any padding, and otherwise after the padding. If <I>w</I> is supplied and the number of other characters to be output is less than <I>w</I>, then copies of <I>padchar</I> (which defaults to a space) are output to make the total field width equal <I>w</I>. Then <I>n</I> digits are printed for the integer part of <I>arg</I>, with leading zeros if necessary; then a decimal point; then <I>d</I> digits of fraction, properly rounded. <P>
|
|
If the magnitude of <I>arg</I> is so large that more than <I>m</I> digits would have to be printed, where <I>m</I> is the larger of <I>w</I> and 100, then an implementation is free, at its discretion, to print the number using exponential notation instead, as if by the directive <TT>~</TT><I>w</I><TT>,</TT><I>q</I><TT>,,,,</TT><I>padchar</I><TT>E</TT>, where <I>w</I> and <I>padchar</I> are present or omitted according to whether they were present or omitted in the <TT>~$</TT> directive, and where <I>q</I>=<I>d</I>+<I>n</I>-1, where <I>d</I> and <I>n</I> are the (possibly default) values given to the <TT>~$</TT> directive. <P>
|
|
If <I>arg</I> is a <A REL=DEFINITION HREF="26_glo_r.htm#rational"><I>rational</I></A> number, then it is coerced to be a <A REL=DEFINITION HREF="26_glo_s.htm#single_float"><I>single float</I></A> and then printed. Alternatively, an implementation is permitted to process a <A REL=DEFINITION HREF="26_glo_r.htm#rational"><I>rational</I></A> number by any other method that has essentially the same behavior but avoids loss of precision or overflow because of the coercion. <P>
|
|
If <I>arg</I> is a <A REL=DEFINITION HREF="26_glo_c.htm#complex"><I>complex</I></A> number or some non-numeric <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>, then it is printed using the format directive <TT>~</TT><I>w</I><TT>D</TT>, thereby printing it in decimal radix and a minimum field width of <I>w</I>. <P>
|
|
<TT>~$</TT> binds <A REL=DEFINITION HREF="v_pr_esc.htm#STprint-escapeST"><B>*print-escape*</B></A> to <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A> and <A REL=DEFINITION HREF="v_pr_rda.htm#STprint-readablyST"><B>*print-readably*</B></A> to <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
|
|
<P>
|
|
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss271.htm">PRINC-READABLY:X3J13-DEC-91</A><LI> <A REL=CHILD HREF="../Issues/iss169.htm">FORMAT-PRETTY-PRINT:YES</A><P></UL><HR>
|
|
|
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
|
|
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
|
</BODY>
|
|
</HTML>
|