Changeset 697e484 for doc/user/user.tex
 Timestamp:
 Mar 26, 2019, 10:30:42 PM (4 years ago)
 Branches:
 armeh, cleanupdtors, enum, forallpointerdecay, jacob/cs343translation, jenkinssandbox, master, newast, newastuniqueexpr, pthreademulation, qualifiedEnum
 Children:
 8a30423
 Parents:
 7726839
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

doc/user/user.tex
r7726839 r697e484 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Tue Dec 11 23:19:26 201814 %% Update Count : 34 0013 %% Last Modified On : Tue Mar 26 22:10:49 2019 14 %% Update Count : 3411 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 508 508 509 509 As for \Index{division}, there are exponentiation operators for integral and floating types, including the builtin \Index{complex} types. 510 Unsigned integral exponentiation\index{exponentiation!unsigned integral} is performed with repeated multiplication\footnote{The multiplication computation is $O(\log y)$.} (or shifting if the baseis 2).511 Signed integral exponentiation\index{exponentiation!signed integral} is performed with repeated multiplication (or shifting if the base is 2), but yields a floating result because $x^{y}=1/x^y$.512 Hence, it is important to designate exponent integralconstants as unsigned or signed: ©3 \ 3u© return an integral result, while ©3 \ 3© returns a floating result.513 Floating exponentiation\index{exponentiation!floating} is performed using \Index{logarithm}s\index{exponentiation!logarithm}, so the base cannot be negative. 514 \begin{cfa} 515 sout  2 ®\® 8u  4 ®\® 3u  4 ®\® 3u  4 ®\® 3  4 ®\® 3  4.0 ®\® 2.1 (1.0f+2.0fi) ®\® (3.0f+2.0fi);516 256 64 64 0.0156250.015625 18.3791736799526 0.2647151.1922i510 Integral exponentiation\index{exponentiation!unsigned integral} is performed with repeated multiplication\footnote{The multiplication computation is $O(\log y)$.} (or shifting if the exponent is 2). 511 Overflow from large exponents or negative exponents return zero. 512 Floating exponentiation\index{exponentiation!floating} is performed using \Index{logarithm}s\index{exponentiation!logarithm}, so the exponent cannot be negative. 513 \begin{cfa} 514 sout  1 ®\® 0  1 ®\® 1  2 ®\® 8  4 ®\® 3  5 ®\® 3  5 ®\® 32  5L ®\® 32  5L ®\® 64  4 ®\® 3  4.0 ®\® 3  4.0 ®\® 2.1 515  (1.0f+2.0fi) ®\® (3.0f+2.0fi); 516 1 1 256 64 125 0 3273344365508751233 0 0 0.015625 18.3791736799526 0.2647151.1922i 517 517 \end{cfa} 518 518 Parenthesis are necessary for complex constants or the expression is parsed as ©1.0f+®(®2.0fi \ 3.0f®)®+2.0fi©. 519 The exponentiation operator is available for all the basic types, but for userdefined types, only the integralcomputation versions are available. 520 For returning an integral value, the user type ©T© must define multiplication, ©*©, and one, ©1©; 521 for returning a floating value, an additional divide of type ©T© into a ©double© returning a ©double© (©double ?/?( double, T )©) is necessary for negative exponents. 519 The exponentiation operator is available for all the basic types, but for userdefined types, only the integralcomputation version is available. 520 \begin{cfa} 521 forall( otype OT  { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) 522 OT ?®\®?( OT ep, unsigned int y ); 523 forall( otype OT  { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) 524 OT ?®\®?( OT ep, unsigned long int y ); 525 \end{cfa} 526 The user type ©T© must define multiplication one, ©1©, and, ©*©. 522 527 523 528 … … 1320 1325 \end{cfa} 1321 1326 Essentially, the return type is wrapped around the routine name in successive layers (like an \Index{onion}). 1322 While attempting to make the two contexts consistent is a laudable goal, it has not worked out in practice. 1327 While attempting to make the two contexts consistent is a laudable goal, it has not worked out in practice, even though Dennis Richie believed otherwise: 1328 \begin{quote} 1329 In spite of its difficulties, I believe that the C's approach to declarations remains plausible, and am comfortable with it; it is a useful unifying principle.~\cite[p.~12]{Ritchie93} 1330 \end{quote} 1323 1331 1324 1332 \CFA provides its own type, variable and routine declarations, using a different syntax.
Note: See TracChangeset
for help on using the changeset viewer.