My various dotfiles

chap-12.texi 166KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504
  1. @node Numbers (Numbers), Characters, Packages, Top
  2. @chapter Numbers
  3. @menu
  4. * Number Concepts::
  5. * Numbers Dictionary::
  6. @end menu
  7. @node Number Concepts, Numbers Dictionary, Numbers (Numbers), Numbers (Numbers)
  8. @section Number Concepts
  9. @c including concept-numbers
  10. @menu
  11. * Numeric Operations::
  12. * Implementation-Dependent Numeric Constants::
  13. * Rational Computations::
  14. * Floating-point Computations::
  15. * Complex Computations::
  16. * Interval Designators::
  17. * Random-State Operations::
  18. @end menu
  19. @node Numeric Operations, Implementation-Dependent Numeric Constants, Number Concepts, Number Concepts
  20. @subsection Numeric Operations
  21. @r{Common Lisp} provides a large variety of operations related to @i{numbers}.
  22. This section provides an overview of those operations by grouping them
  23. into categories that emphasize some of the relationships among them.
  24. Figure 12--1 shows @i{operators} relating to
  25. arithmetic operations.
  26. @group
  27. @noindent
  28. @w{ * 1+ gcd }
  29. @w{ + 1- incf }
  30. @w{ - conjugate lcm }
  31. @w{ / decf }
  32. @noindent
  33. @w{ Figure 12--1: Operators relating to Arithmetic.}
  34. @end group
  35. Figure 12--2 shows @i{defined names} relating to
  36. exponential, logarithmic, and trigonometric operations.
  37. @group
  38. @noindent
  39. @w{ abs cos signum }
  40. @w{ acos cosh sin }
  41. @w{ acosh exp sinh }
  42. @w{ asin expt sqrt }
  43. @w{ asinh isqrt tan }
  44. @w{ atan log tanh }
  45. @w{ atanh phase }
  46. @w{ cis pi }
  47. @noindent
  48. @w{ Figure 12--2: Defined names relating to Exponentials, Logarithms, and Trigonometry.}
  49. @end group
  50. Figure 12--3 shows @i{operators} relating to
  51. numeric comparison and predication.
  52. @group
  53. @noindent
  54. @w{ /= >= oddp }
  55. @w{ < evenp plusp }
  56. @w{ <= max zerop }
  57. @w{ = min }
  58. @w{ > minusp }
  59. @noindent
  60. @w{ Figure 12--3: Operators for numeric comparison and predication.}
  61. @end group
  62. Figure 12--4 shows @i{defined names} relating to
  63. numeric type manipulation and coercion.
  64. @group
  65. @noindent
  66. @w{ ceiling float-radix rational }
  67. @w{ complex float-sign rationalize }
  68. @w{ decode-float floor realpart }
  69. @w{ denominator fround rem }
  70. @w{ fceiling ftruncate round }
  71. @w{ ffloor imagpart scale-float }
  72. @w{ float integer-decode-float truncate }
  73. @w{ float-digits mod }
  74. @w{ float-precision numerator }
  75. @noindent
  76. @w{ Figure 12--4: Defined names relating to numeric type manipulation and coercion.}
  77. @end group
  78. @menu
  79. * Associativity and Commutativity in Numeric Operations::
  80. * Examples of Associativity and Commutativity in Numeric Operations::
  81. * Contagion in Numeric Operations::
  82. * Viewing Integers as Bits and Bytes::
  83. * Logical Operations on Integers::
  84. * Byte Operations on Integers::
  85. @end menu
  86. @node Associativity and Commutativity in Numeric Operations, Examples of Associativity and Commutativity in Numeric Operations, Numeric Operations, Numeric Operations
  87. @subsubsection Associativity and Commutativity in Numeric Operations
  88. For functions that are mathematically associative (and possibly commutative),
  89. a @i{conforming implementation} may process the @i{arguments} in any manner
  90. consistent with associative (and possibly commutative) rearrangement. This does not
  91. affect the order in which the @i{argument} @i{forms} are @i{evaluated};
  92. for a discussion of evaluation order, see @ref{Function Forms}.
  93. What is unspecified is only the order in which the @i{parameter} @i{values}
  94. are processed. This implies that @i{implementations} may differ in which
  95. automatic @i{coercions} are applied; see @ref{Contagion in Numeric Operations}.
  96. A @i{conforming program} can control the order of processing explicitly by
  97. separating the operations into separate (possibly nested) @i{function forms},
  98. or by writing explicit calls to @i{functions} that perform coercions.
  99. @node Examples of Associativity and Commutativity in Numeric Operations, Contagion in Numeric Operations, Associativity and Commutativity in Numeric Operations, Numeric Operations
  100. @subsubsection Examples of Associativity and Commutativity in Numeric Operations
  101. Consider the following expression, in which we assume that @t{1.0} and
  102. @t{1.0e-15} both denote @i{single floats}:
  103. @example
  104. (+ 1/3 2/3 1.0d0 1.0 1.0e-15)
  105. @end example
  106. One @i{conforming implementation} might
  107. process the @i{arguments} from left to right,
  108. first adding @t{1/3} and @t{2/3} to get @t{1},
  109. then converting that to a @i{double float}
  110. for combination with @t{1.0d0},
  111. then successively converting and adding @t{1.0} and @t{1.0e-15}.
  112. Another @i{conforming implementation} might process the @i{arguments} from
  113. right to left, first performing a @i{single float} addition of @t{1.0} and
  114. @t{1.0e-15} (perhaps losing accuracy in the process), then converting the sum to
  115. a @i{double float} and adding @t{1.0d0}, then converting @t{2/3} to a
  116. @i{double float} and adding it, and then converting @t{1/3} and adding that.
  117. A third @i{conforming implementation} might first scan all the @i{arguments},
  118. process all the @i{rationals} first to keep that part of the computation exact,
  119. then find an @i{argument} of the largest floating-point format among all the
  120. @i{arguments} and add that, and then add in all other @i{arguments}, converting
  121. each in turn (all in a perhaps misguided attempt to make the computation as accurate
  122. as possible).
  123. In any case, all three strategies are legitimate.
  124. A @i{conforming program} could control the order by writing, for example,
  125. @example
  126. (+ (+ 1/3 2/3) (+ 1.0d0 1.0e-15) 1.0)
  127. @end example
  128. @node Contagion in Numeric Operations, Viewing Integers as Bits and Bytes, Examples of Associativity and Commutativity in Numeric Operations, Numeric Operations
  129. @subsubsection Contagion in Numeric Operations
  130. For information about the contagion rules for implicit coercions of @i{arguments}
  131. in numeric operations, see
  132. @ref{Rule of Float Precision Contagion},
  133. @ref{Rule of Float and Rational Contagion},
  134. and @ref{Rule of Complex Contagion}.
  135. @node Viewing Integers as Bits and Bytes, Logical Operations on Integers, Contagion in Numeric Operations, Numeric Operations
  136. @subsubsection Viewing Integers as Bits and Bytes
  137. @node Logical Operations on Integers, Byte Operations on Integers, Viewing Integers as Bits and Bytes, Numeric Operations
  138. @subsubsection Logical Operations on Integers
  139. Logical operations require @i{integers} as arguments;
  140. an error of @i{type} @b{type-error} should be signaled
  141. if an argument is supplied that is not an @i{integer}.
  142. @i{Integer} arguments to logical operations are treated as if
  143. they were represented in two's-complement notation.
  144. Figure 12--5 shows @i{defined names} relating to
  145. logical operations on numbers.
  146. @group
  147. @noindent
  148. @w{ ash boole-ior logbitp }
  149. @w{ boole boole-nand logcount }
  150. @w{ boole-1 boole-nor logeqv }
  151. @w{ boole-2 boole-orc1 logior }
  152. @w{ boole-and boole-orc2 lognand }
  153. @w{ boole-andc1 boole-set lognor }
  154. @w{ boole-andc2 boole-xor lognot }
  155. @w{ boole-c1 integer-length logorc1 }
  156. @w{ boole-c2 logand logorc2 }
  157. @w{ boole-clr logandc1 logtest }
  158. @w{ boole-eqv logandc2 logxor }
  159. @noindent
  160. @w{ Figure 12--5: Defined names relating to logical operations on numbers.}
  161. @end group
  162. @node Byte Operations on Integers, , Logical Operations on Integers, Numeric Operations
  163. @subsubsection Byte Operations on Integers
  164. The byte-manipulation @i{functions} use @i{objects}
  165. called @i{byte specifiers} to designate the size and position
  166. of a specific @i{byte} within an @i{integer}.
  167. The representation of a @i{byte specifier} is @i{implementation-dependent};
  168. it might or might not be a @i{number}.
  169. The @i{function} @b{byte} will construct a @i{byte specifier},
  170. which various other byte-manipulation @i{functions} will accept.
  171. Figure 12--6 shows @i{defined names} relating to
  172. manipulating @i{bytes} of @i{numbers}.
  173. @group
  174. @noindent
  175. @w{ byte deposit-field ldb-test }
  176. @w{ byte-position dpb mask-field }
  177. @w{ byte-size ldb }
  178. @noindent
  179. @w{ Figure 12--6: Defined names relating to byte manipulation.}
  180. @end group
  181. @node Implementation-Dependent Numeric Constants, Rational Computations, Numeric Operations, Number Concepts
  182. @subsection Implementation-Dependent Numeric Constants
  183. Figure 12--7 shows @i{defined names} relating to
  184. @i{implementation-dependent} details about @i{numbers}.
  185. @group
  186. @noindent
  187. @w{ double-float-epsilon most-negative-fixnum }
  188. @w{ double-float-negative-epsilon most-negative-long-float }
  189. @w{ least-negative-double-float most-negative-short-float }
  190. @w{ least-negative-long-float most-negative-single-float }
  191. @w{ least-negative-short-float most-positive-double-float }
  192. @w{ least-negative-single-float most-positive-fixnum }
  193. @w{ least-positive-double-float most-positive-long-float }
  194. @w{ least-positive-long-float most-positive-short-float }
  195. @w{ least-positive-short-float most-positive-single-float }
  196. @w{ least-positive-single-float short-float-epsilon }
  197. @w{ long-float-epsilon short-float-negative-epsilon }
  198. @w{ long-float-negative-epsilon single-float-epsilon }
  199. @w{ most-negative-double-float single-float-negative-epsilon }
  200. @noindent
  201. @w{ Figure 12--7: Defined names relating to implementation-dependent details about numbers.}
  202. @end group
  203. @node Rational Computations, Floating-point Computations, Implementation-Dependent Numeric Constants, Number Concepts
  204. @subsection Rational Computations
  205. The rules in this section apply to @i{rational} computations.
  206. @menu
  207. * Rule of Unbounded Rational Precision::
  208. * Rule of Canonical Representation for Rationals::
  209. * Rule of Float Substitutability::
  210. @end menu
  211. @node Rule of Unbounded Rational Precision, Rule of Canonical Representation for Rationals, Rational Computations, Rational Computations
  212. @subsubsection Rule of Unbounded Rational Precision
  213. Rational computations cannot overflow in the usual sense
  214. (though there may not be enough storage to represent a result),
  215. since @i{integers} and @i{ratios} may in principle be of any magnitude.
  216. @node Rule of Canonical Representation for Rationals, Rule of Float Substitutability, Rule of Unbounded Rational Precision, Rational Computations
  217. @subsubsection Rule of Canonical Representation for Rationals
  218. If any computation produces a result that is a mathematical ratio of two integers
  219. such that the denominator evenly divides the numerator, then the result is converted
  220. to the equivalent @i{integer}.
  221. If the denominator does not evenly divide the numerator,
  222. the canonical representation of a @i{rational} number is as the @i{ratio}
  223. that numerator and that denominator, where the greatest common divisor of
  224. the numerator and denominator is one, and where the denominator is positive
  225. and greater than one.
  226. When used as input (in the default syntax),
  227. the notation @t{-0} always denotes the @i{integer} @t{0}.
  228. A @i{conforming implementation} must not have a
  229. representation of ``minus zero'' for @i{integers}
  230. that is distinct from its representation of zero for @i{integers}.
  231. However, such a distinction is possible for @i{floats};
  232. see the @i{type} @b{float}.
  233. @node Rule of Float Substitutability, , Rule of Canonical Representation for Rationals, Rational Computations
  234. @subsubsection Rule of Float Substitutability
  235. When the arguments to an irrational mathematical @i{function}
  236. [Reviewer Note by Barmar: There should be a table of these functions.]
  237. are all @i{rational} and the true mathematical result
  238. is also (mathematically) rational, then unless otherwise noted
  239. an implementation is free to return either an accurate
  240. @i{rational} result
  241. or a @i{single float} approximation.
  242. If the arguments are all @i{rational}
  243. but the result cannot be expressed
  244. as a @i{rational} number, then a @i{single float}
  245. approximation is always returned.
  246. If the arguments to a mathematical @i{function} are all of type
  247. @t{(or rational (complex rational))}
  248. and the true mathematical result is
  249. (mathematically) a complex number with rational real and imaginary
  250. parts, then unless otherwise noted an implementation is free to return
  251. either an accurate result of type @t{(or rational (complex rational))}
  252. or
  253. a @i{single float}
  254. (permissible only if the imaginary part of the true mathematical
  255. result is zero) or @t{(complex single-float)}. If the arguments are
  256. all of type @t{(or rational (complex rational))}
  257. but the result cannot be
  258. expressed as a @i{rational} or @i{complex rational},
  259. then the returned
  260. value will be of @i{type} @b{single-float}
  261. (permissible only if the imaginary
  262. part of the true mathematical result is zero) or @t{(complex single-float)}.
  263. @group
  264. @noindent
  265. @w{ Function Sample Results }
  266. @w{ @b{abs} @t{(abs #c(3 4)) @result{} 5 @i{or} 5.0} }
  267. @w{ @b{acos} @t{(acos 1) @result{} 0 @i{or} 0.0} }
  268. @w{ @b{acosh} @t{(acosh 1) @result{} 0 @i{or} 0.0} }
  269. @w{ @b{asin} @t{(asin 0) @result{} 0 @i{or} 0.0} }
  270. @w{ @b{asinh} @t{(asinh 0) @result{} 0 @i{or} 0.0} }
  271. @w{ @b{atan} @t{(atan 0) @result{} 0 @i{or} 0.0} }
  272. @w{ @b{atanh} @t{(atanh 0) @result{} 0 @i{or} 0.0} }
  273. @w{ @b{cis} @t{(cis 0) @result{} #c(1 0) @i{or} #c(1.0 0.0)} }
  274. @w{ @b{cos} @t{(cos 0) @result{} 1 @i{or} 1.0} }
  275. @w{ @b{cosh} @t{(cosh 0) @result{} 1 @i{or} 1.0} }
  276. @w{ @b{exp} @t{(exp 0) @result{} 1 @i{or} 1.0} }
  277. @w{ @b{expt} @t{(expt 8 1/3) @result{} 2 @i{or} 2.0} }
  278. @w{ @b{log} @t{(log 1) @result{} 0 @i{or} 0.0} }
  279. @w{ @t{(log 8 2) @result{} 3 @i{or} 3.0} }
  280. @w{ @b{phase} @t{(phase 7) @result{} 0 @i{or} 0.0} }
  281. @w{ @b{signum} @t{(signum #c(3 4)) @result{} #c(3/5 4/5) @i{or} #c(0.6 0.8)} }
  282. @w{ @b{sin} @t{(sin 0) @result{} 0 @i{or} 0.0} }
  283. @w{ @b{sinh} @t{(sinh 0) @result{} 0 @i{or} 0.0} }
  284. @w{ @b{sqrt} @t{(sqrt 4) @result{} 2 @i{or} 2.0} }
  285. @w{ @t{(sqrt 9/16) @result{} 3/4 @i{or} 0.75} }
  286. @w{ @b{tan} @t{(tan 0) @result{} 0 @i{or} 0.0} }
  287. @w{ @b{tanh} @t{(tanh 0) @result{} 0 @i{or} 0.0} }
  288. @noindent
  289. @w{ Figure 12--8: Functions Affected by Rule of Float Substitutability}
  290. @end group
  291. @node Floating-point Computations, Complex Computations, Rational Computations, Number Concepts
  292. @subsection Floating-point Computations
  293. The following rules apply to floating point computations.
  294. @menu
  295. * Rule of Float and Rational Contagion::
  296. * Examples of Rule of Float and Rational Contagion::
  297. * Rule of Float Approximation::
  298. * Rule of Float Underflow and Overflow::
  299. * Rule of Float Precision Contagion::
  300. @end menu
  301. @node Rule of Float and Rational Contagion, Examples of Rule of Float and Rational Contagion, Floating-point Computations, Floating-point Computations
  302. @subsubsection Rule of Float and Rational Contagion
  303. When @i{rationals} and @i{floats} are combined by a numerical function,
  304. the @i{rational} is first converted to a @i{float} of the same format.
  305. For @i{functions} such as @b{+} that take more than two arguments,
  306. it is permitted that part of the operation be carried out exactly using
  307. @i{rationals} and the rest be done using floating-point arithmetic.
  308. When @i{rationals} and @i{floats} are compared by a numerical function,
  309. the @i{function} @b{rational} is effectively called to convert the @i{float}
  310. to a @i{rational} and then an exact
  311. comparison is performed. In the case of @i{complex} numbers,
  312. the real and imaginary parts are effectively handled individually.
  313. @node Examples of Rule of Float and Rational Contagion, Rule of Float Approximation, Rule of Float and Rational Contagion, Floating-point Computations
  314. @subsubsection Examples of Rule of Float and Rational Contagion
  315. @example
  316. ;;;; Combining rationals with floats.
  317. ;;; This example assumes an implementation in which
  318. ;;; (float-radix 0.5) is 2 (as in IEEE) or 16 (as in IBM/360),
  319. ;;; or else some other implementation in which 1/2 has an exact
  320. ;;; representation in floating point.
  321. (+ 1/2 0.5) @result{} 1.0
  322. (- 1/2 0.5d0) @result{} 0.0d0
  323. (+ 0.5 -0.5 1/2) @result{} 0.5
  324. ;;;; Comparing rationals with floats.
  325. ;;; This example assumes an implementation in which the default float
  326. ;;; format is IEEE single-float, IEEE double-float, or some other format
  327. ;;; in which 5/7 is rounded upwards by FLOAT.
  328. (< 5/7 (float 5/7)) @result{} @i{true}
  329. (< 5/7 (rational (float 5/7))) @result{} @i{true}
  330. (< (float 5/7) (float 5/7)) @result{} @i{false}
  331. @end example
  332. @node Rule of Float Approximation, Rule of Float Underflow and Overflow, Examples of Rule of Float and Rational Contagion, Floating-point Computations
  333. @subsubsection Rule of Float Approximation
  334. Computations with @i{floats} are only approximate,
  335. although they are described as if the results
  336. were mathematically accurate.
  337. Two mathematically identical
  338. expressions may be computationally different because of errors
  339. inherent in the floating-point approximation process.
  340. The precision of a @i{float} is not necessarily
  341. correlated with the accuracy of that number.
  342. For instance, 3.142857142857142857 is a more precise approximation
  343. to \pi than 3.14159, but the latter is more accurate.
  344. The precision refers to the number of bits retained in the representation.
  345. When an operation combines a @i{short float} with a
  346. @i{long float},
  347. the result will be a @i{long float}.
  348. @r{Common Lisp} functions assume that the accuracy of
  349. arguments to them does not exceed their precision. Therefore
  350. when two @i{small floats}
  351. are combined, the result is a @i{small float}.
  352. @r{Common Lisp} functions
  353. never convert automatically from a larger size to a smaller one.
  354. @node Rule of Float Underflow and Overflow, Rule of Float Precision Contagion, Rule of Float Approximation, Floating-point Computations
  355. @subsubsection Rule of Float Underflow and Overflow
  356. An error of @i{type} @b{floating-point-overflow}
  357. or @b{floating-point-underflow} should be signaled if a
  358. floating-point computation causes exponent overflow or underflow, respectively.
  359. @node Rule of Float Precision Contagion, , Rule of Float Underflow and Overflow, Floating-point Computations
  360. @subsubsection Rule of Float Precision Contagion
  361. The result of a numerical function is a @i{float} of the
  362. largest format among all the floating-point arguments to the @i{function}.
  363. @node Complex Computations, Interval Designators, Floating-point Computations, Number Concepts
  364. @subsection Complex Computations
  365. The following rules apply to @i{complex} computations:
  366. @menu
  367. * Rule of Complex Substitutability::
  368. * Rule of Complex Contagion::
  369. * Rule of Canonical Representation for Complex Rationals::
  370. * Examples of Rule of Canonical Representation for Complex Rationals::
  371. * Principal Values and Branch Cuts::
  372. @end menu
  373. @node Rule of Complex Substitutability, Rule of Complex Contagion, Complex Computations, Complex Computations
  374. @subsubsection Rule of Complex Substitutability
  375. Except during the execution of irrational and transcendental @i{functions},
  376. no numerical @i{function} ever @i{yields} a @i{complex} unless
  377. one or more of its @i{arguments} is a @i{complex}.
  378. @node Rule of Complex Contagion, Rule of Canonical Representation for Complex Rationals, Rule of Complex Substitutability, Complex Computations
  379. @subsubsection Rule of Complex Contagion
  380. When a
  381. @i{real}
  382. and
  383. a @i{complex} are both part of a computation,
  384. the
  385. @i{real}
  386. is first converted to a @i{complex} by providing an imaginary part of @t{0}.
  387. @node Rule of Canonical Representation for Complex Rationals, Examples of Rule of Canonical Representation for Complex Rationals, Rule of Complex Contagion, Complex Computations
  388. @subsubsection Rule of Canonical Representation for Complex Rationals
  389. If the result of any computation would be a @i{complex}
  390. number whose real part is of @i{type} @b{rational} and whose imaginary
  391. part is zero, the result is converted to the @i{rational}
  392. which is the real part.
  393. This rule does not apply to @i{complex} numbers whose parts
  394. are @i{floats}.
  395. For example, @t{#C(5 0)} and @t{5} are not @i{different} @i{objects} in @r{Common Lisp}
  396. (they are always the @i{same} under @b{eql});
  397. @t{#C(5.0 0.0)} and @t{5.0} are always @i{different} @i{objects} in @r{Common Lisp}
  398. (they are never the @i{same} under @b{eql},
  399. although they are the @i{same} under @b{equalp} and @b{=}).
  400. @node Examples of Rule of Canonical Representation for Complex Rationals, Principal Values and Branch Cuts, Rule of Canonical Representation for Complex Rationals, Complex Computations
  401. @subsubsection Examples of Rule of Canonical Representation for Complex Rationals
  402. @example
  403. #c(1.0 1.0) @result{} #C(1.0 1.0)
  404. #c(0.0 0.0) @result{} #C(0.0 0.0)
  405. #c(1.0 1) @result{} #C(1.0 1.0)
  406. #c(0.0 0) @result{} #C(0.0 0.0)
  407. #c(1 1) @result{} #C(1 1)
  408. #c(0 0) @result{} 0
  409. (typep #c(1 1) '(complex (eql 1))) @result{} @i{true}
  410. (typep #c(0 0) '(complex (eql 0))) @result{} @i{false}
  411. @end example
  412. @node Principal Values and Branch Cuts, , Examples of Rule of Canonical Representation for Complex Rationals, Complex Computations
  413. @subsubsection Principal Values and Branch Cuts
  414. Many of the irrational and transcendental functions are multiply defined
  415. in the complex domain; for example, there are in general an infinite
  416. number of complex values for the logarithm function. In each such
  417. case, a @i{principal} @i{value} must be chosen for the function to return.
  418. In general, such values cannot be chosen so as to make the range
  419. continuous; lines in the domain
  420. called branch cuts must be defined, which in turn
  421. define the discontinuities in the range.
  422. @r{Common Lisp} defines the branch cuts, @i{principal} @i{values}, and boundary
  423. conditions for the complex functions following ``{Principal Values and Branch Cuts in Complex APL}.'' The branch
  424. cut rules that apply to each function are located with the description of
  425. that function.
  426. Figure 12--9 lists
  427. the identities that are obeyed
  428. throughout the applicable portion of the complex domain, even on
  429. the branch cuts:
  430. @group
  431. @noindent
  432. @w{ sin i z = i sinh z sinh i z = i sin z arctan i z = i arctanh z }
  433. @w{ cos i z = cosh z cosh i z = cos z arcsinh i z = i arcsin z }
  434. @w{ tan i z = i tanh z arcsin i z = i arcsinh z arctanh i z = i arctan z }
  435. @noindent
  436. @w{ Figure 12--9: Trigonometric Identities for Complex Domain }
  437. @end group
  438. The quadrant numbers referred to in the discussions of branch cuts are as illustrated
  439. in Figure 12--10.
  440. @example
  441. Imaginary Axis
  442. |
  443. |
  444. II | I
  445. |
  446. |
  447. |
  448. ______________________________________ Real Axis
  449. |
  450. |
  451. |
  452. III | IV
  453. |
  454. |
  455. |
  456. |
  457. @end example
  458. @w{ Figure 12--9: Quadrant Numbering for Branch Cuts}
  459. @node Interval Designators, Random-State Operations, Complex Computations, Number Concepts
  460. @subsection Interval Designators
  461. The @i{compound type specifier} form of the numeric @i{type specifiers}
  462. in Figure 12--10 permit the user to specify an interval on the real number line
  463. which describe a @i{subtype} of the @i{type} which would be described by the
  464. corresponding @i{atomic type specifier}. A @i{subtype} of some @i{type}
  465. @i{T} is specified using an ordered pair of @i{objects} called
  466. @i{interval designators} for @i{type} @i{T}.
  467. The first of the two @i{interval designators} for @i{type} @i{T} can be
  468. any of the following:
  469. @table @asis
  470. @item a number @i{N} of @i{type} @i{T}
  471. This denotes a lower inclusive bound of @i{N}. That is, @i{elements}
  472. of the @i{subtype} of @i{T} will be greater than or equal to @i{N}.
  473. @item a @i{singleton} @i{list} whose @i{element} is
  474. a number @i{M} of @i{type} @i{T}
  475. This denotes a lower exclusive bound of @i{M}. That is, @i{elements}
  476. of the @i{subtype} of @i{T} will be greater than @i{M}.
  477. @item the symbol @b{*}
  478. This denotes the absence of a lower bound on the interval.
  479. @end table
  480. The second of the two @i{interval designators} for @i{type} @i{T} can be
  481. any of the following:
  482. @table @asis
  483. @item a number @i{N} of @i{type} @i{T}
  484. This denotes an upper inclusive bound of @i{N}. That is, @i{elements}
  485. of the @i{subtype} of @i{T} will be less than or equal to @i{N}.
  486. @item a @i{singleton} @i{list} whose @i{element} is
  487. a number @i{M} of @i{type} @i{T}
  488. This denotes an upper exclusive bound of @i{M}. That is, @i{elements}
  489. of the @i{subtype} of @i{T} will be less than @i{M}.
  490. @item the symbol @b{*}
  491. This denotes the absence of an upper bound on the interval.
  492. @end table
  493. @node Random-State Operations, , Interval Designators, Number Concepts
  494. @subsection Random-State Operations
  495. Figure 12--10 lists some @i{defined names} that are applicable to @i{random states}.
  496. @group
  497. @noindent
  498. @w{ *random-state* random }
  499. @w{ make-random-state random-state-p }
  500. @noindent
  501. @w{ Figure 12--10: Random-state defined names}
  502. @end group
  503. @c end of including concept-numbers
  504. @node Numbers Dictionary, , Number Concepts, Numbers (Numbers)
  505. @section Numbers Dictionary
  506. @c including dict-numbers
  507. @menu
  508. * number::
  509. * complex (System Class)::
  510. * real::
  511. * float (System Class)::
  512. * short-float::
  513. * rational::
  514. * ratio::
  515. * integer::
  516. * signed-byte::
  517. * unsigned-byte::
  518. * mod::
  519. * bit::
  520. * fixnum::
  521. * bignum::
  522. * =::
  523. * max::
  524. * minusp::
  525. * zerop::
  526. * floor::
  527. * sin::
  528. * asin::
  529. * pi::
  530. * sinh::
  531. * *::
  532. * +::
  533. * -::
  534. * /::
  535. * 1+::
  536. * abs::
  537. * evenp::
  538. * exp::
  539. * gcd::
  540. * incf::
  541. * lcm::
  542. * log::
  543. * mod::
  544. * signum::
  545. * sqrt::
  546. * random-state::
  547. * make-random-state::
  548. * random::
  549. * random-state-p::
  550. * *random-state*::
  551. * numberp::
  552. * cis::
  553. * complex::
  554. * complexp::
  555. * conjugate::
  556. * phase::
  557. * realpart::
  558. * upgraded-complex-part-type::
  559. * realp::
  560. * numerator::
  561. * rational::
  562. * rationalp::
  563. * ash::
  564. * integer-length::
  565. * integerp::
  566. * parse-integer::
  567. * boole::
  568. * boole-1::
  569. * logand::
  570. * logbitp::
  571. * logcount::
  572. * logtest::
  573. * byte::
  574. * deposit-field::
  575. * dpb::
  576. * ldb::
  577. * ldb-test::
  578. * mask-field::
  579. * most-positive-fixnum::
  580. * decode-float::
  581. * float::
  582. * floatp::
  583. * most-positive-short-float::
  584. * short-float-epsilon::
  585. * arithmetic-error::
  586. * arithmetic-error-operands::
  587. * division-by-zero::
  588. * floating-point-invalid-operation::
  589. * floating-point-inexact::
  590. * floating-point-overflow::
  591. * floating-point-underflow::
  592. @end menu
  593. @node number, complex (System Class), Numbers Dictionary, Numbers Dictionary
  594. @subsection number [System Class]
  595. @subsubheading Class Precedence List::
  596. @b{number},
  597. @b{t}
  598. @subsubheading Description::
  599. The @i{type} @b{number} contains @i{objects} which represent
  600. mathematical numbers.
  601. The @i{types} @b{real} and @b{complex} are @i{disjoint}
  602. @i{subtypes} of @b{number}.
  603. The @i{function} @b{=} tests for numerical equality.
  604. The @i{function} @b{eql}, when its arguments are both @i{numbers},
  605. tests that they have both the same @i{type} and numerical value.
  606. Two @i{numbers} that are the @i{same} under @b{eql} or @b{=}
  607. are not necessarily the @i{same} under @b{eq}.
  608. @subsubheading Notes::
  609. @r{Common Lisp} differs from mathematics on some naming issues. In mathematics,
  610. the set of real numbers is traditionally described as a subset of the
  611. complex numbers, but in @r{Common Lisp}, the @i{type} @b{real} and the @i{type} @b{complex} are
  612. disjoint. The @r{Common Lisp} type which includes all mathematical complex
  613. numbers is called @b{number}. The reasons for these differences
  614. include historical precedent, compatibility with most other popular
  615. computer languages, and various issues of time and space efficiency.
  616. @node complex (System Class), real, number, Numbers Dictionary
  617. @subsection complex [System Class]
  618. @subsubheading Class Precedence List::
  619. @b{complex},
  620. @b{number},
  621. @b{t}
  622. @subsubheading Description::
  623. The @i{type} @b{complex} includes all mathematical complex numbers
  624. other than those included in the @i{type} @b{rational}.
  625. @i{Complexes} are
  626. expressed
  627. in Cartesian form with a
  628. real part and an imaginary part, each of which is a @i{real}.
  629. The real part and imaginary part are either both
  630. @i{rational} or both of the same @i{float} @i{type}.
  631. The imaginary part can be a @i{float} zero, but can never
  632. be a @i{rational} zero, for such a number is always represented
  633. by @r{Common Lisp} as a @i{rational} rather than a @i{complex}.
  634. @subsubheading Compound Type Specifier Kind::
  635. Specializing.
  636. @subsubheading Compound Type Specifier Syntax::
  637. (@code{complex}@{@i{@t{[}typespec | @b{*}@t{]}}@})
  638. @subsubheading Compound Type Specifier Arguments::
  639. @i{typespec}---a @i{type specifier} that denotes a @i{subtype} of @i{type} @b{real}.
  640. @subsubheading Compound Type Specifier Description::
  641. [Editorial Note by KMP: If you ask me, this definition is a complete mess. Looking at
  642. issue ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING does not help me figure
  643. it out, either. Anyone got any suggestions?]
  644. Every element of this @i{type} is a @i{complex} whose
  645. real part and imaginary part are each of type
  646. @t{(upgraded-complex-part-type @i{typespec})}.
  647. This @i{type} encompasses those @i{complexes}
  648. that can result by giving numbers of @i{type} @i{typespec}
  649. to @b{complex}.
  650. @t{(complex @i{type-specifier})}
  651. refers to all @i{complexes} that can result from giving
  652. @i{numbers} of @i{type} @i{type-specifier} to the @i{function} @b{complex},
  653. plus all other @i{complexes} of the same specialized representation.
  654. @subsubheading See Also::
  655. @ref{Rule of Canonical Representation for Complex Rationals},
  656. @ref{Constructing Numbers from Tokens},
  657. @ref{Printing Complexes}
  658. @subsubheading Notes::
  659. The input syntax for a @i{complex} with real part r and
  660. imaginary part i is @t{#C(r i)}.
  661. For further details, see @ref{Standard Macro Characters}.
  662. For every @i{float}, n, there is a @i{complex}
  663. which represents the same mathematical number
  664. and which can be obtained by @t{(COERCE n 'COMPLEX)}.
  665. @node real, float (System Class), complex (System Class), Numbers Dictionary
  666. @subsection real [System Class]
  667. @subsubheading Class Precedence List::
  668. @b{real},
  669. @b{number},
  670. @b{t}
  671. @subsubheading Description::
  672. The @i{type} @b{real} includes all @i{numbers} that
  673. represent mathematical real numbers, though there are mathematical real
  674. numbers (@i{e.g.}, irrational numbers) that do not have an exact representation
  675. in @r{Common Lisp}. Only @i{reals} can be ordered using the
  676. @b{<}, @b{>}, @b{<=}, and @b{>=} functions.
  677. The @i{types} @b{rational} and @b{float} are @i{disjoint}
  678. @i{subtypes} of @i{type} @b{real}.
  679. @subsubheading Compound Type Specifier Kind::
  680. Abbreviating.
  681. @subsubheading Compound Type Specifier Syntax::
  682. (@code{real}@{@i{@t{[}lower-limit @r{[}upper-limit@r{]}@t{]}}@})
  683. @subsubheading Compound Type Specifier Arguments::
  684. @i{lower-limit}, @i{upper-limit}---@i{interval designators}
  685. for @i{type} @b{real}.
  686. The defaults for each of @i{lower-limit} and @i{upper-limit} is the @i{symbol} @b{*}.
  687. @subsubheading Compound Type Specifier Description::
  688. This denotes the @i{reals} on the interval described by
  689. @i{lower-limit} and @i{upper-limit}.
  690. @node float (System Class), short-float, real, Numbers Dictionary
  691. @subsection float [System Class]
  692. @subsubheading Class Precedence List::
  693. @b{float},
  694. @b{real},
  695. @b{number},
  696. @b{t}
  697. @subsubheading Description::
  698. A @i{float}
  699. is a mathematical rational (but @i{not} a @r{Common Lisp} @i{rational})
  700. of the form
  701. s\cdot f\cdot b^{e-p},
  702. where s is +1 or -1, the @i{sign};
  703. b is an @i{integer}
  704. greater than~1, the @i{base} or @i{radix} of the representation;
  705. p is a positive @i{integer},
  706. the @i{precision} (in base-b digits) of the @i{float};
  707. f is a positive @i{integer}
  708. between b^{p-1} and
  709. b^p-1 (inclusive), the significand;
  710. and e is an @i{integer}, the exponent.
  711. The value of p and the range of~e
  712. depends on the implementation and on the type of @i{float}
  713. within that implementation. In addition, there is a floating-point zero;
  714. depending on the implementation, there can also be a ``minus zero''. If there
  715. is no minus zero, then 0.0 and~-0.0 are both interpreted as simply a
  716. floating-point zero.
  717. @t{(= 0.0 -0.0)} is always true.
  718. If there is a minus zero, @t{(eql -0.0 0.0)} is @i{false},
  719. otherwise it is @i{true}.
  720. [Reviewer Note by Barmar: What about IEEE NaNs and infinities?]
  721. [Reviewer Note by RWK: In the following, what is the ``ordering''? precision? range?
  722. Can there be additional subtypes of float or does ``others'' in the
  723. list of four?]
  724. The @i{types} @b{short-float}, @b{single-float}, @b{double-float},
  725. and @b{long-float} are @i{subtypes} of @i{type} @b{float}. Any two of them must be
  726. either @i{disjoint} @i{types} or the @i{same} @i{type};
  727. if the @i{same} @i{type}, then any other @i{types} between them in the
  728. above ordering must also be the @i{same} @i{type}. For example,
  729. if the @i{type} @b{single-float} and the @i{type} @b{long-float} are the @i{same} @i{type},
  730. then the @i{type} @b{double-float} must be the @i{same} @i{type} also.
  731. @subsubheading Compound Type Specifier Kind::
  732. Abbreviating.
  733. @subsubheading Compound Type Specifier Syntax::
  734. (@code{float}@{@i{@t{[}lower-limit @r{[}upper-limit@r{]}@t{]}}@})
  735. @subsubheading Compound Type Specifier Arguments::
  736. @i{lower-limit}, @i{upper-limit}---@i{interval designators}
  737. for @i{type} @b{float}.
  738. The defaults for each of @i{lower-limit} and @i{upper-limit} is the @i{symbol} @b{*}.
  739. @subsubheading Compound Type Specifier Description::
  740. This denotes the @i{floats} on the interval described by
  741. @i{lower-limit} and @i{upper-limit}.
  742. @subsubheading See Also::
  743. {@i{Figure~2--9}},
  744. @ref{Constructing Numbers from Tokens},
  745. @ref{Printing Floats}
  746. @subsubheading Notes::
  747. Note that all mathematical integers are representable not only as
  748. @r{Common Lisp} @i{reals}, but also as @i{complex floats}. For example,
  749. possible representations of the mathematical number 1
  750. include the @i{integer} @t{1},
  751. the @i{float} @t{1.0},
  752. or the @i{complex} @t{#C(1.0 0.0)}.
  753. @node short-float, rational, float (System Class), Numbers Dictionary
  754. @subsection short-float, single-float, double-float, long-float [Type]
  755. @subsubheading Supertypes::
  756. @b{short-float}:
  757. @b{short-float},
  758. @b{float},
  759. @b{real},
  760. @b{number},
  761. @b{t}
  762. @b{single-float}:
  763. @b{single-float},
  764. @b{float},
  765. @b{real},
  766. @b{number},
  767. @b{t}
  768. @b{double-float}:
  769. @b{double-float},
  770. @b{float},
  771. @b{real},
  772. @b{number},
  773. @b{t}
  774. @b{long-float}:
  775. @b{long-float},
  776. @b{float},
  777. @b{real},
  778. @b{number},
  779. @b{t}
  780. @subsubheading Description::
  781. For the four defined @i{subtypes} of @i{type} @b{float}, it is true that
  782. intermediate between the @i{type} @b{short-float} and the @i{type} @b{long-float} are
  783. the @i{type} @b{single-float} and the @i{type} @b{double-float}.
  784. The precise definition of these categories is
  785. @i{implementation-defined}.
  786. The precision (measured in ``bits'', computed as p\log_2b)
  787. and the exponent size (also measured in ``bits,'' computed as
  788. \log_2(n+1), where n is the maximum exponent value) is recommended
  789. to be at least as great
  790. as the values in Figure 12--11.
  791. Each of the defined @i{subtypes} of @i{type} @b{float} might or might not have a minus zero.
  792. @group
  793. @noindent
  794. @w{ @b{Format} @b{Minimum Precision} @b{Minimum Exponent Size} }
  795. @w{ __________________________________________________}
  796. @w{ Short 13 bits 5 bits }
  797. @w{ Single 24 bits 8 bits }
  798. @w{ Double 50 bits 8 bits }
  799. @w{ Long 50 bits 8 bits }
  800. @noindent
  801. @w{ Figure 12--11: Recommended Minimum Floating-Point Precision and Exponent Size}
  802. @end group
  803. There can be fewer than four internal
  804. representations for @i{floats}.
  805. If there are fewer distinct representations, the following rules apply:
  806. @table @asis
  807. @item --
  808. If there is only one, it is
  809. the @i{type} @b{single-float}.
  810. In this representation, an @i{object} is simultaneously of @i{types}
  811. @b{single-float}, @b{double-float}, @b{short-float},
  812. and @b{long-float}.
  813. @item --
  814. Two internal representations can be arranged in either of the
  815. following ways:
  816. @table @asis
  817. @item @t{*}
  818. Two @i{types} are provided: @b{single-float} and
  819. @b{short-float}. An @i{object} is simultaneously
  820. of @i{types} @b{single-float}, @b{double-float}, and @b{long-float}.
  821. @item @t{*}
  822. Two @i{types} are provided: @b{single-float} and
  823. @b{double-float}. An @i{object} is simultaneously of @i{types}
  824. @b{single-float} and @b{short-float}, or
  825. @b{double-float} and @b{long-float}.
  826. @end table
  827. @item --
  828. Three internal representations can be arranged in either
  829. of the following ways:
  830. @table @asis
  831. @item @t{*}
  832. Three @i{types} are provided: @b{short-float},
  833. @b{single-float}, and @b{double-float}.
  834. An @i{object} can simultaneously be of @i{type} @b{double-float}
  835. and @b{long-float}.
  836. @item @t{*}
  837. Three @i{types} are provided:
  838. @b{single-float}, @b{double-float},
  839. and @b{long-float}. An @i{object} can simultaneously
  840. be of @i{types} @b{single-float} and @b{short-float}.
  841. @end table
  842. @end table
  843. @subsubheading Compound Type Specifier Kind::
  844. Abbreviating.
  845. @subsubheading Compound Type Specifier Syntax::
  846. (@code{short-float}@{@i{@t{[}short-lower-limit @r{[}short-upper-limit@r{]}@t{]}}@})
  847. (@code{single-float}@{@i{@t{[}single-lower-limit @r{[}single-upper-limit@r{]}@t{]}}@})
  848. (@code{double-float}@{@i{@t{[}double-lower-limit @r{[}double-upper-limit@r{]}@t{]}}@})
  849. (@code{long-float}@{@i{@t{[}long-lower-limit @r{[}long-upper-limit@r{]}@t{]}}@})
  850. @subsubheading Compound Type Specifier Arguments::
  851. @i{short-lower-limit}, @i{short-upper-limit}---@i{interval designators}
  852. for @i{type} @b{short-float}.
  853. The defaults for each of @i{lower-limit} and @i{upper-limit} is the @i{symbol} @b{*}.
  854. @i{single-lower-limit}, @i{single-upper-limit}---@i{interval designators}
  855. for @i{type} @b{single-float}.
  856. The defaults for each of @i{lower-limit} and @i{upper-limit} is the @i{symbol} @b{*}.
  857. @i{double-lower-limit}, @i{double-upper-limit}---@i{interval designators}
  858. for @i{type} @b{double-float}.
  859. The defaults for each of @i{lower-limit} and @i{upper-limit} is the @i{symbol} @b{*}.
  860. @i{long-lower-limit}, @i{long-upper-limit}---@i{interval designators}
  861. for @i{type} @b{long-float}.
  862. The defaults for each of @i{lower-limit} and @i{upper-limit} is the @i{symbol} @b{*}.
  863. @subsubheading Compound Type Specifier Description::
  864. Each of these denotes the set of @i{floats} of the indicated @i{type}
  865. that are on the interval specified by the @i{interval designators}.
  866. @node rational, ratio, short-float, Numbers Dictionary
  867. @subsection rational [System Class]
  868. @subsubheading Class Precedence List::
  869. @b{rational},
  870. @b{real},
  871. @b{number},
  872. @b{t}
  873. @subsubheading Description::
  874. The canonical representation of a @i{rational}
  875. is as an @i{integer} if its value is integral,
  876. and otherwise as a @i{ratio}.
  877. The @i{types} @b{integer} and @b{ratio}
  878. are @i{disjoint} @i{subtypes} of @i{type} @b{rational}.
  879. @subsubheading Compound Type Specifier Kind::
  880. Abbreviating.
  881. @subsubheading Compound Type Specifier Syntax::
  882. (@code{rational}@{@i{@t{[}lower-limit @r{[}upper-limit@r{]}@t{]}}@})
  883. @subsubheading Compound Type Specifier Arguments::
  884. @i{lower-limit}, @i{upper-limit}---@i{interval designators}
  885. for @i{type} @b{rational}.
  886. The defaults for each of @i{lower-limit} and @i{upper-limit} is the @i{symbol} @b{*}.
  887. @subsubheading Compound Type Specifier Description::
  888. This denotes the @i{rationals} on the interval described by
  889. @i{lower-limit} and @i{upper-limit}.
  890. @node ratio, integer, rational, Numbers Dictionary
  891. @subsection ratio [System Class]
  892. @subsubheading Class Precedence List::
  893. @b{ratio},
  894. @b{rational},
  895. @b{real},
  896. @b{number},
  897. @b{t}
  898. @subsubheading Description::
  899. A @i{ratio} is a @i{number}
  900. representing the mathematical ratio of two non-zero integers,
  901. the numerator and denominator,
  902. whose greatest common divisor is one,
  903. and of which the denominator is positive and greater than one.
  904. @subsubheading See Also::
  905. {@i{Figure~2--9}},
  906. @ref{Constructing Numbers from Tokens},
  907. @ref{Printing Ratios}
  908. @node integer, signed-byte, ratio, Numbers Dictionary
  909. @subsection integer [System Class]
  910. @subsubheading Class Precedence List::
  911. @b{integer},
  912. @b{rational},
  913. @b{real},
  914. @b{number},
  915. @b{t}
  916. @subsubheading Description::
  917. An @i{integer} is a mathematical integer. There is no limit on the
  918. magnitude of an @i{integer}.
  919. The @i{types} @b{fixnum} and @b{bignum}
  920. form an @i{exhaustive partition} of @i{type} @b{integer}.
  921. @subsubheading Compound Type Specifier Kind::
  922. Abbreviating.
  923. @subsubheading Compound Type Specifier Syntax::
  924. (@code{integer}@{@i{@t{[}lower-limit @r{[}upper-limit@r{]}@t{]}}@})
  925. @subsubheading Compound Type Specifier Arguments::
  926. @i{lower-limit}, @i{upper-limit}---@i{interval designators}
  927. for @i{type} @b{integer}.
  928. The defaults for each of @i{lower-limit} and @i{upper-limit} is the @i{symbol} @b{*}.
  929. @subsubheading Compound Type Specifier Description::
  930. This denotes the @i{integers} on the interval described by
  931. @i{lower-limit} and @i{upper-limit}.
  932. @subsubheading See Also::
  933. {@i{Figure~2--9}},
  934. @ref{Constructing Numbers from Tokens},
  935. @ref{Printing Integers}
  936. @subsubheading Notes::
  937. The @i{type} @t{(integer @i{lower} @i{upper})},
  938. where @i{lower} and @i{upper}
  939. are @b{most-negative-fixnum} and @b{most-positive-fixnum}, respectively,
  940. is also called @b{fixnum}.
  941. The @i{type} @t{(integer 0 1)} is also called @b{bit}.
  942. The @i{type} @t{(integer 0 *)} is also called @b{unsigned-byte}.
  943. @node signed-byte, unsigned-byte, integer, Numbers Dictionary
  944. @subsection signed-byte [Type]
  945. @subsubheading Supertypes::
  946. @b{signed-byte},
  947. @b{integer},
  948. @b{rational},
  949. @b{real},
  950. @b{number},
  951. @b{t}
  952. @subsubheading Description::
  953. The atomic @i{type specifier} @b{signed-byte} denotes the same
  954. type as is denoted by the @i{type specifier} @b{integer};
  955. however, the list forms of these two @i{type specifiers} have different semantics.
  956. @subsubheading Compound Type Specifier Kind::
  957. Abbreviating.
  958. @subsubheading Compound Type Specifier Syntax::
  959. (@code{signed-byte}@{@i{@t{[}s | @b{*}@t{]}}@})
  960. @subsubheading Compound Type Specifier Arguments::
  961. @i{s}---a positive @i{integer}.
  962. @subsubheading Compound Type Specifier Description::
  963. This denotes the set of @i{integers} that can be represented
  964. in two's-complement form in a @i{byte} of @i{s} bits. This is
  965. equivalent to @t{(integer -2^{s-1} 2^{s-1}-1)}. The type
  966. @b{signed-byte} or the type @t{(signed-byte *)} is the same
  967. as the @i{type} @b{integer}.
  968. @node unsigned-byte, mod, signed-byte, Numbers Dictionary
  969. @subsection unsigned-byte [Type]
  970. @subsubheading Supertypes::
  971. @b{unsigned-byte},
  972. @b{signed-byte},
  973. @b{integer},
  974. @b{rational},
  975. @b{real},
  976. @b{number},
  977. @b{t}
  978. @subsubheading Description::
  979. The atomic @i{type specifier} @b{unsigned-byte} denotes the same
  980. type as is denoted by the @i{type specifier} @t{(integer 0 *)}.
  981. @subsubheading Compound Type Specifier Kind::
  982. Abbreviating.
  983. @subsubheading Compound Type Specifier Syntax::
  984. (@code{unsigned-byte}@{@i{@t{[}@i{s} | @b{*}@t{]}}@})
  985. @subsubheading Compound Type Specifier Arguments::
  986. @i{s}---a positive @i{integer}.
  987. @subsubheading Compound Type Specifier Description::
  988. This denotes the set of non-negative @i{integers} that can be
  989. represented in a byte of size @i{s} (bits).
  990. This is equivalent
  991. to @t{(mod @i{m})} for @i{m}=2^s, or
  992. to @t{(integer 0 @i{n})} for @i{n}=2^s-1.
  993. The @i{type} @b{unsigned-byte} or
  994. the type @t{(unsigned-byte *)} is the same as
  995. the type @t{(integer 0 *)}, the set of non-negative @i{integers}.
  996. @subsubheading Notes::
  997. The @i{type} @t{(unsigned-byte 1)} is also called @b{bit}.
  998. @node mod, bit, unsigned-byte, Numbers Dictionary
  999. @subsection mod [Type Specifier]
  1000. @subsubheading Compound Type Specifier Kind::
  1001. Abbreviating.
  1002. @subsubheading Compound Type Specifier Syntax::
  1003. (@code{mod}@{@i{n}@})
  1004. @subsubheading Compound Type Specifier Arguments::
  1005. @i{n}---a positive @i{integer}.
  1006. @subsubheading Compound Type Specifier Description::
  1007. This denotes the set of non-negative @i{integers} less than @i{n}.
  1008. This is equivalent to
  1009. @t{(integer 0 (@i{n}))}
  1010. or to
  1011. @t{(integer 0 @i{m})},
  1012. where @i{m}=@i{n}-1.
  1013. The argument is required, and cannot be @b{*}.
  1014. The symbol @b{mod} is not valid as a @i{type specifier}.
  1015. @node bit, fixnum, mod, Numbers Dictionary
  1016. @subsection bit [Type]
  1017. @subsubheading Supertypes::
  1018. @b{bit},
  1019. @b{unsigned-byte},
  1020. @b{signed-byte},
  1021. @b{integer},
  1022. @b{rational},
  1023. @b{real},
  1024. @b{number},
  1025. @b{t}
  1026. @subsubheading Description::
  1027. The @i{type} @b{bit} is equivalent to the @i{type} @t{(integer 0 1)}
  1028. and @t{(unsigned-byte 1)}.
  1029. @node fixnum, bignum, bit, Numbers Dictionary
  1030. @subsection fixnum [Type]
  1031. @subsubheading Supertypes::
  1032. @b{fixnum},
  1033. @b{integer},
  1034. @b{rational},
  1035. @b{real},
  1036. @b{number},
  1037. @b{t}
  1038. @subsubheading Description::
  1039. A @i{fixnum} is an @i{integer} whose value is between
  1040. @b{most-negative-fixnum} and @b{most-positive-fixnum} inclusive.
  1041. Exactly which @i{integers} are @i{fixnums} is
  1042. @i{implementation-defined}.
  1043. The @i{type} @b{fixnum} is required to be a supertype of
  1044. @t{(signed-byte 16)}.
  1045. @node bignum, =, fixnum, Numbers Dictionary
  1046. @subsection bignum [Type]
  1047. @subsubheading Supertypes::
  1048. @b{bignum},
  1049. @b{integer},
  1050. @b{rational},
  1051. @b{real},
  1052. @b{number},
  1053. @b{t}
  1054. @subsubheading Description::
  1055. The @i{type} @b{bignum} is defined to be exactly @t{(and integer (not fixnum))}.
  1056. @node =, max, bignum, Numbers Dictionary
  1057. @subsection =, /=, <, >, <=, >= [Function]
  1058. @code{=} @i{{&rest} numbers^+} @result{} @i{generalized-boolean}
  1059. @code{/=} @i{{&rest} numbers^+} @result{} @i{generalized-boolean}
  1060. @code{<} @i{{&rest} numbers^+} @result{} @i{generalized-boolean}
  1061. @code{>} @i{{&rest} numbers^+} @result{} @i{generalized-boolean}
  1062. @code{<=} @i{{&rest} numbers^+} @result{} @i{generalized-boolean}
  1063. @code{>=} @i{{&rest} numbers^+} @result{} @i{generalized-boolean}
  1064. @subsubheading Arguments and Values::
  1065. @i{number}---for @b{<}, @b{>}, @b{<=}, @b{>=}: a @i{real};
  1066. for @b{=}, @b{/=}: a @i{number}.
  1067. @i{generalized-boolean}---a @i{generalized boolean}.
  1068. @subsubheading Description::
  1069. @b{=}, @b{/=}, @b{<}, @b{>}, @b{<=}, and @b{>=}
  1070. perform arithmetic comparisons on their arguments as follows:
  1071. @table @asis
  1072. @item @b{=}
  1073. The value of @b{=} is @i{true} if all @i{numbers} are the same in value;
  1074. otherwise it is @i{false}.
  1075. Two @i{complexes} are considered equal by @b{=}
  1076. if their real and imaginary parts are equal according to @b{=}.
  1077. @item @b{/=}
  1078. The value of @b{/=} is @i{true} if no two @i{numbers} are the same in value;
  1079. otherwise it is @i{false}.
  1080. @item @b{<}
  1081. The value of @b{<} is @i{true} if the @i{numbers} are in monotonically increasing order;
  1082. otherwise it is @i{false}.
  1083. @item @b{>}
  1084. The value of @b{>} is @i{true} if the @i{numbers} are in monotonically decreasing order;
  1085. otherwise it is @i{false}.
  1086. @item @b{<=}
  1087. The value of @b{<=} is @i{true} if the @i{numbers} are in monotonically
  1088. nondecreasing order;
  1089. otherwise it is @i{false}.
  1090. @item @b{>=}
  1091. The value of @b{>=} is @i{true} if the @i{numbers} are in monotonically
  1092. nonincreasing order;
  1093. otherwise it is @i{false}.
  1094. @end table
  1095. @b{=}, @b{/=}, @b{<}, @b{>}, @b{<=}, and @b{>=}
  1096. perform necessary type conversions.
  1097. @subsubheading Examples::
  1098. The uses of these functions are illustrated in Figure 12--12.
  1099. @group
  1100. @noindent
  1101. @w{ @t{(= 3 3)} is @i{true}. @t{(/= 3 3)} is @i{false}. }
  1102. @w{ @t{(= 3 5)} is @i{false}. @t{(/= 3 5)} is @i{true}. }
  1103. @w{ @t{(= 3 3 3 3)} is @i{true}. @t{(/= 3 3 3 3)} is @i{false}. }
  1104. @w{ @t{(= 3 3 5 3)} is @i{false}. @t{(/= 3 3 5 3)} is @i{false}. }
  1105. @w{ @t{(= 3 6 5 2)} is @i{false}. @t{(/= 3 6 5 2)} is @i{true}. }
  1106. @w{ @t{(= 3 2 3)} is @i{false}. @t{(/= 3 2 3)} is @i{false}. }
  1107. @w{ @t{(< 3 5)} is @i{true}. @t{(<= 3 5)} is @i{true}. }
  1108. @w{ @t{(< 3 -5)} is @i{false}. @t{(<= 3 -5)} is @i{false}. }
  1109. @w{ @t{(< 3 3)} is @i{false}. @t{(<= 3 3)} is @i{true}. }
  1110. @w{ @t{(< 0 3 4 6 7)} is @i{true}. @t{(<= 0 3 4 6 7)} is @i{true}. }
  1111. @w{ @t{(< 0 3 4 4 6)} is @i{false}. @t{(<= 0 3 4 4 6)} is @i{true}. }
  1112. @w{ @t{(> 4 3)} is @i{true}. @t{(>= 4 3)} is @i{true}. }
  1113. @w{ @t{(> 4 3 2 1 0)} is @i{true}. @t{(>= 4 3 2 1 0)} is @i{true}. }
  1114. @w{ @t{(> 4 3 3 2 0)} is @i{false}. @t{(>= 4 3 3 2 0)} is @i{true}. }
  1115. @w{ @t{(> 4 3 1 2 0)} is @i{false}. @t{(>= 4 3 1 2 0)} is @i{false}. }
  1116. @w{ @t{(= 3)} is @i{true}. @t{(/= 3)} is @i{true}. }
  1117. @w{ @t{(< 3)} is @i{true}. @t{(<= 3)} is @i{true}. }
  1118. @w{ @t{(= 3.0 #c(3.0 0.0))} is @i{true}. @t{(/= 3.0 #c(3.0 1.0))} is @i{true}. }
  1119. @w{ @t{(= 3 3.0)} is @i{true}. @t{(= 3.0s0 3.0d0)} is @i{true}. }
  1120. @w{ @t{(= 0.0 -0.0)} is @i{true}. @t{(= 5/2 2.5)} is @i{true}. }
  1121. @w{ @t{(> 0.0 -0.0)} is @i{false}. @t{(= 0 -0.0)} is @i{true}. }
  1122. @w{ @t{(<= 0 x 9)} is @i{true} if @t{x} is between @t{0} and @t{9}, inclusive}
  1123. @w{ @t{(< 0.0 x 1.0)} is @i{true} if @t{x} is between @t{0.0} and @t{1.0}, exclusive}
  1124. @w{ @t{(< -1 j (length v))} is @i{true} if @t{j} is a @i{valid array index} for a @i{vector} @t{v}}
  1125. @noindent
  1126. @w{ Figure 12--12: Uses of /=, =, <, >, <=, and >= }
  1127. @end group
  1128. @subsubheading Exceptional Situations::
  1129. Might signal @b{type-error} if some @i{argument} is not a @i{real}.
  1130. Might signal @b{arithmetic-error} if otherwise unable to fulfill its contract.
  1131. @subsubheading Notes::
  1132. @b{=} differs from @b{eql} in that
  1133. @t{(= 0.0 -0.0)} is always true,
  1134. because @b{=} compares the mathematical values of its operands,
  1135. whereas @b{eql} compares the representational values, so to speak.
  1136. @node max, minusp, =, Numbers Dictionary
  1137. @subsection max, min [Function]
  1138. @code{max} @i{{&rest} reals^+} @result{} @i{max-real}
  1139. @code{min} @i{{&rest} reals^+} @result{} @i{min-real}
  1140. @subsubheading Arguments and Values::
  1141. @i{real}---a @i{real}.
  1142. @i{max-real}, @i{min-real}---a @i{real}.
  1143. @subsubheading Description::
  1144. @b{max} returns the @i{real} that is greatest (closest to positive infinity).
  1145. @b{min} returns the @i{real} that is least (closest to negative infinity).
  1146. For @b{max},
  1147. the implementation has the choice of returning the largest
  1148. argument as is or applying the rules of floating-point @i{contagion},
  1149. taking all the arguments into consideration for @i{contagion} purposes.
  1150. Also, if one or more of the arguments are @b{=}, then any one
  1151. of them may be chosen as the value to return.
  1152. For example, if the @i{reals} are a mixture of @i{rationals} and @i{floats},
  1153. and the largest argument is a @i{rational},
  1154. then the implementation is free to
  1155. produce either that @i{rational}
  1156. or its @i{float} approximation;
  1157. if the largest argument is a
  1158. @i{float} of a smaller format
  1159. than the largest format of any @i{float} argument,
  1160. then the implementation is free to
  1161. return the argument in its given format or expanded to the larger format.
  1162. Similar remarks apply to @b{min}
  1163. (replacing ``largest argument'' by ``smallest argument'').
  1164. @subsubheading Examples::
  1165. @example
  1166. (max 3) @result{} 3
  1167. (min 3) @result{} 3
  1168. (max 6 12) @result{} 12
  1169. (min 6 12) @result{} 6
  1170. (max -6 -12) @result{} -6
  1171. (min -6 -12) @result{} -12
  1172. (max 1 3 2 -7) @result{} 3
  1173. (min 1 3 2 -7) @result{} -7
  1174. (max -2 3 0 7) @result{} 7
  1175. (min -2 3 0 7) @result{} -2
  1176. (max 5.0 2) @result{} 5.0
  1177. (min 5.0 2)
  1178. @result{} 2
  1179. @i{OR}@result{} 2.0
  1180. (max 3.0 7 1)
  1181. @result{} 7
  1182. @i{OR}@result{} 7.0
  1183. (min 3.0 7 1)
  1184. @result{} 1
  1185. @i{OR}@result{} 1.0
  1186. (max 1.0s0 7.0d0) @result{} 7.0d0
  1187. (min 1.0s0 7.0d0)
  1188. @result{} 1.0s0
  1189. @i{OR}@result{} 1.0d0
  1190. (max 3 1 1.0s0 1.0d0)
  1191. @result{} 3
  1192. @i{OR}@result{} 3.0d0
  1193. (min 3 1 1.0s0 1.0d0)
  1194. @result{} 1
  1195. @i{OR}@result{} 1.0s0
  1196. @i{OR}@result{} 1.0d0
  1197. @end example
  1198. @subsubheading Exceptional Situations::
  1199. Should signal an error of @i{type} @b{type-error}
  1200. if any @i{number} is not a @i{real}.
  1201. @node minusp, zerop, max, Numbers Dictionary
  1202. @subsection minusp, plusp [Function]
  1203. @code{minusp} @i{real} @result{} @i{generalized-boolean}
  1204. @code{plusp} @i{real} @result{} @i{generalized-boolean}
  1205. @subsubheading Arguments and Values::
  1206. @i{real}---a @i{real}.
  1207. @i{generalized-boolean}---a @i{generalized boolean}.
  1208. @subsubheading Description::
  1209. @b{minusp} returns @i{true} if @i{real} is less than zero;
  1210. otherwise, returns @i{false}.
  1211. @b{plusp} returns @i{true} if @i{real} is greater than zero;
  1212. otherwise, returns @i{false}.
  1213. Regardless of whether an @i{implementation} provides distinct
  1214. representations for positive and negative @i{float} zeros,
  1215. @t{(minusp -0.0)} always returns @i{false}.
  1216. @subsubheading Examples::
  1217. @example
  1218. (minusp -1) @result{} @i{true}
  1219. (plusp 0) @result{} @i{false}
  1220. (plusp least-positive-single-float) @result{} @i{true}
  1221. @end example
  1222. @subsubheading Exceptional Situations::
  1223. Should signal an error of @i{type} @b{type-error}
  1224. if @i{real} is not a @i{real}.
  1225. @node zerop, floor, minusp, Numbers Dictionary
  1226. @subsection zerop [Function]
  1227. @code{zerop} @i{number} @result{} @i{generalized-boolean}
  1228. @subsubheading Pronunciation::
  1229. pronounced 'z\=e (, )r\=o{}(, )p\=e
  1230. @subsubheading Arguments and Values::
  1231. @i{number}---a @i{number}.
  1232. @i{generalized-boolean}---a @i{generalized boolean}.
  1233. @subsubheading Description::
  1234. Returns @i{true} if @i{number} is zero (@i{integer}, @i{float}, or @i{complex});
  1235. otherwise, returns @i{false}.
  1236. Regardless of whether an @i{implementation} provides distinct representations
  1237. for positive and negative floating-point zeros, @t{(zerop -0.0)}
  1238. always returns @i{true}.
  1239. @subsubheading Examples::
  1240. @example
  1241. (zerop 0) @result{} @i{true}
  1242. (zerop 1) @result{} @i{false}
  1243. (zerop -0.0) @result{} @i{true}
  1244. (zerop 0/100) @result{} @i{true}
  1245. (zerop #c(0 0.0)) @result{} @i{true}
  1246. @end example
  1247. @subsubheading Exceptional Situations::
  1248. Should signal an error of @i{type} @b{type-error}
  1249. if @i{number} is not a @i{number}.
  1250. @subsubheading Notes::
  1251. @example
  1252. (zerop @i{number}) @equiv{} (= @i{number} 0)
  1253. @end example
  1254. @node floor, sin, zerop, Numbers Dictionary
  1255. @subsection floor, ffloor, ceiling, fceiling,
  1256. @subheading truncate, ftruncate, round, fround
  1257. @flushright
  1258. @i{[Function]}
  1259. @end flushright
  1260. @code{floor} @i{number {&optional} divisor} @result{} @i{quotient, remainder}
  1261. @code{ffloor} @i{number {&optional} divisor} @result{} @i{quotient, remainder}
  1262. @code{ceiling} @i{number {&optional} divisor} @result{} @i{quotient, remainder}
  1263. @code{fceiling} @i{number {&optional} divisor} @result{} @i{quotient, remainder}
  1264. @code{truncate} @i{number {&optional} divisor} @result{} @i{quotient, remainder}
  1265. @code{ftruncate} @i{number {&optional} divisor} @result{} @i{quotient, remainder}
  1266. @code{round} @i{number {&optional} divisor} @result{} @i{quotient, remainder}
  1267. @code{fround} @i{number {&optional} divisor} @result{} @i{quotient, remainder}
  1268. @subsubheading Arguments and Values::
  1269. @i{number}---a @i{real}.
  1270. @i{divisor}---a non-zero @i{real}.
  1271. The default is the @i{integer} @t{1}.
  1272. @i{quotient}---for @b{floor}, @b{ceiling},
  1273. @b{truncate}, and @b{round}: an @i{integer};
  1274. for @b{ffloor}, @b{fceiling},
  1275. @b{ftruncate}, and @b{fround}: a @i{float}.
  1276. @i{remainder}---a @i{real}.
  1277. @subsubheading Description::
  1278. These functions divide @i{number} by @i{divisor},
  1279. returning a @i{quotient} and @i{remainder}, such that
  1280. @i{quotient}{\cdot} @i{divisor}+@i{remainder}=@i{number}
  1281. The @i{quotient} always represents a mathematical integer.
  1282. When more than one mathematical integer might be possible
  1283. (@i{i.e.}, when the remainder is not zero),
  1284. the kind of rounding or truncation depends on the @i{operator}:
  1285. @table @asis
  1286. @item @b{floor}, @b{ffloor}
  1287. @b{floor} and @b{ffloor} produce a @i{quotient}
  1288. that has been truncated toward negative infinity;
  1289. that is, the @i{quotient} represents the largest mathematical integer
  1290. that is not larger than the mathematical quotient.
  1291. @item @b{ceiling}, @b{fceiling}
  1292. @b{ceiling} and @b{fceiling} produce a @i{quotient}
  1293. that has been truncated toward positive infinity;
  1294. that is, the @i{quotient} represents the smallest mathematical integer
  1295. that is not smaller than the mathematical result.
  1296. @item @b{truncate}, @b{ftruncate}
  1297. @b{truncate} and @b{ftruncate} produce a @i{quotient}
  1298. that has been truncated towards zero;
  1299. that is, the @i{quotient} represents the mathematical integer
  1300. of the same sign as the mathematical quotient, and
  1301. that has the greatest integral magnitude not greater than that of the mathematical quotient.
  1302. @item @b{round}, @b{fround}
  1303. @b{round} and @b{fround} produce a @i{quotient}
  1304. that has been rounded to the nearest mathematical integer;
  1305. if the mathematical quotient is exactly halfway between two integers,
  1306. (that is, it has the form @i{integer}+1\over2),
  1307. then the @i{quotient} has been rounded to the even (divisible by two) integer.
  1308. @end table
  1309. All of these functions perform type conversion operations on @i{numbers}.
  1310. The @i{remainder}
  1311. is an @i{integer} if both @t{x} and @t{y} are @i{integers},
  1312. is a @i{rational} if both @t{x} and @t{y} are @i{rationals}, and
  1313. is a @i{float} if either @t{x} or @t{y} is a @i{float}.
  1314. @b{ffloor}, @b{fceiling}, @b{ftruncate}, and @b{fround}
  1315. handle arguments of different @i{types} in the following way:
  1316. If @i{number} is a @i{float},
  1317. and @i{divisor} is not a @i{float} of longer format,
  1318. then the first result is a @i{float} of the same @i{type} as @i{number}.
  1319. Otherwise, the first result is of the @i{type} determined by @i{contagion} rules;
  1320. see @ref{Contagion in Numeric Operations}.
  1321. @subsubheading Examples::
  1322. @example
  1323. (floor 3/2) @result{} 1, 1/2
  1324. (ceiling 3 2) @result{} 2, -1
  1325. (ffloor 3 2) @result{} 1.0, 1
  1326. (ffloor -4.7) @result{} -5.0, 0.3
  1327. (ffloor 3.5d0) @result{} 3.0d0, 0.5d0
  1328. (fceiling 3/2) @result{} 2.0, -1/2
  1329. (truncate 1) @result{} 1, 0
  1330. (truncate .5) @result{} 0, 0.5
  1331. (round .5) @result{} 0, 0.5
  1332. (ftruncate -7 2) @result{} -3.0, -1
  1333. (fround -7 2) @result{} -4.0, 1
  1334. (dolist (n '(2.6 2.5 2.4 0.7 0.3 -0.3 -0.7 -2.4 -2.5 -2.6))
  1335. (format t "~&~4,1@@F ~2,' D ~2,' D ~2,' D ~2,' D"
  1336. n (floor n) (ceiling n) (truncate n) (round n)))
  1337. @t{ |> } +2.6 2 3 2 3
  1338. @t{ |> } +2.5 2 3 2 2
  1339. @t{ |> } +2.4 2 3 2 2
  1340. @t{ |> } +0.7 0 1 0 1
  1341. @t{ |> } +0.3 0 1 0 0
  1342. @t{ |> } -0.3 -1 0 0 0
  1343. @t{ |> } -0.7 -1 0 0 -1
  1344. @t{ |> } -2.4 -3 -2 -2 -2
  1345. @t{ |> } -2.5 -3 -2 -2 -2
  1346. @t{ |> } -2.6 -3 -2 -2 -3
  1347. @result{} NIL
  1348. @end example
  1349. @subsubheading Notes::
  1350. When only @i{number} is given, the two results are exact;
  1351. the mathematical sum of the two results is always equal to the
  1352. mathematical value of @i{number}.
  1353. @t{(@i{function} @i{number} @i{divisor})}
  1354. and @t{(@i{function} (/ @i{number} @i{divisor}))}
  1355. (where @i{function} is any of one
  1356. of @b{floor}, @b{ceiling}, @b{ffloor},
  1357. @b{fceiling}, @b{truncate},
  1358. @b{round}, @b{ftruncate}, and @b{fround})
  1359. return the same first value, but
  1360. they return different remainders as the second value. For example:
  1361. @example
  1362. (floor 5 2) @result{} 2, 1
  1363. (floor (/ 5 2)) @result{} 2, 1/2
  1364. @end example
  1365. If an effect is desired that is similar to @b{round},
  1366. but that always rounds up or down (rather than toward the nearest even integer)
  1367. if the mathematical quotient is exactly halfway between two integers,
  1368. the programmer should consider a construction such as
  1369. @t{(floor (+ x 1/2))}
  1370. or @t{(ceiling (- x 1/2))}.
  1371. @node sin, asin, floor, Numbers Dictionary
  1372. @subsection sin, cos, tan [Function]
  1373. @code{sin} @i{radians} @result{} @i{number}
  1374. @code{cos} @i{radians} @result{} @i{number}
  1375. @code{tan} @i{radians} @result{} @i{number}
  1376. @subsubheading Arguments and Values::
  1377. @i{radians}---a @i{number} given in radians.
  1378. @i{number}---a @i{number}.
  1379. @subsubheading Description::
  1380. @b{sin}, @b{cos}, and @b{tan}
  1381. return the sine, cosine, and tangent, respectively, of @i{radians}.
  1382. @subsubheading Examples::
  1383. @example
  1384. (sin 0) @result{} 0.0
  1385. (cos 0.7853982) @result{} 0.707107
  1386. (tan #c(0 1)) @result{} #C(0.0 0.761594)
  1387. @end example
  1388. @subsubheading Exceptional Situations::
  1389. Should signal an error of @i{type} @b{type-error}
  1390. if @i{radians} is not a @i{number}.
  1391. Might signal @b{arithmetic-error}.
  1392. @subsubheading See Also::
  1393. @ref{asin; acos; atan}
  1394. ,
  1395. @b{acos},
  1396. @b{atan},
  1397. @ref{Rule of Float Substitutability}
  1398. @node asin, pi, sin, Numbers Dictionary
  1399. @subsection asin, acos, atan [Function]
  1400. @code{asin} @i{number} @result{} @i{radians}
  1401. @code{acos} @i{number} @result{} @i{radians}
  1402. @code{atan} @i{number1 {&optional} number2} @result{} @i{radians}
  1403. @subsubheading Arguments and Values::
  1404. @i{number}---a @i{number}.
  1405. @i{number1}---a @i{number} if @i{number2} is not supplied,
  1406. or a @i{real} if @i{number2} is supplied.
  1407. @i{number2}---a @i{real}.
  1408. @i{radians}---a @i{number} (of radians).
  1409. @subsubheading Description::
  1410. @b{asin}, @b{acos}, and @b{atan}
  1411. compute the arc sine, arc cosine, and arc tangent respectively.
  1412. The arc sine, arc cosine, and arc tangent (with only @i{number1} supplied)
  1413. functions can be defined mathematically for
  1414. @i{number} or @i{number1} specified as @i{x} as in Figure 12--13.
  1415. @group
  1416. @noindent
  1417. @w{ Function Definition }
  1418. @w{ Arc sine -i @t{log} (ix+ \sqrt{1-x^2} ) }
  1419. @w{ Arc cosine (\pi/2) - @t{arcsin} x }
  1420. @w{ Arc tangent -i @t{log} ((1+ix) \sqrt{1/(1+x^2)} ) }
  1421. @noindent
  1422. @w{ Figure 12--13: Mathematical definition of arc sine, arc cosine, and arc tangent}
  1423. @end group
  1424. These formulae are mathematically correct, assuming
  1425. completely accurate computation. They are not necessarily
  1426. the simplest ones for real-valued computations.
  1427. If both @i{number1} and @i{number2} are supplied
  1428. for @b{atan}, the result is the arc tangent
  1429. of @i{number1}/@i{number2}.
  1430. The value of @b{atan} is always between
  1431. -\pi (exclusive) and~\pi (inclusive)
  1432. when minus zero is not supported.
  1433. The range of the two-argument arc tangent when minus zero is supported
  1434. includes -\pi.
  1435. For a
  1436. @i{real}
  1437. @i{number1},
  1438. the result is
  1439. a @i{real}
  1440. and lies between
  1441. -\pi/2 and~\pi/2 (both exclusive).
  1442. @i{number1} can be a @i{complex} if @i{number2}
  1443. is not supplied. If both are supplied, @i{number2} can be zero provided
  1444. @i{number1} is not zero.
  1445. [Reviewer Note by Barmar: Should add ``However, if the implementation distinguishes
  1446. positive and negative zero, both may be signed zeros,
  1447. and limits are used to define the result.'']
  1448. The following definition for arc sine determines the range and
  1449. branch cuts:
  1450. @center @t{arcsin} z = -i @t{log} (iz+\sqrt{1-z^2}\Bigr)
  1451. The branch cut for the arc sine function is in two pieces:
  1452. one along the negative real axis to the left of~-1
  1453. (inclusive), continuous with quadrant II, and one along the positive real
  1454. axis to the right of~1 (inclusive), continuous with quadrant IV. The
  1455. range is that strip of the complex plane containing numbers whose real
  1456. part is between -\pi/2 and~\pi/2. A number with real
  1457. part equal to -\pi/2 is in the range if and only if its imaginary
  1458. part is non-negative; a number with real part equal to \pi/2 is in
  1459. the range if and only if its imaginary part is non-positive.
  1460. The following definition for arc cosine determines the range and
  1461. branch cuts:
  1462. @center @t{arccos} z = {\pi\over2}- @t{arcsin} z
  1463. or, which are equivalent,
  1464. @center @t{arccos} z = -i @t{log} (z+i \sqrt{1-z^2}\Bigr)
  1465. @center @t{arccos} z = {{2 @t{log} (\sqrt{(1+z)/2} + i \sqrt{(1-z)/2})}\over{i}}
  1466. The branch cut for the arc cosine function is in two pieces:
  1467. one along the negative real axis to the left of~-1
  1468. (inclusive), continuous with quadrant II, and one along the positive real
  1469. axis to the right of~1 (inclusive), continuous with quadrant IV.
  1470. This is the same branch cut as for arc sine.
  1471. The range is that strip of the complex plane containing numbers whose real
  1472. part is between 0 and~\pi. A number with real
  1473. part equal to 0 is in the range if and only if its imaginary
  1474. part is non-negative; a number with real part equal to \pi is in
  1475. the range if and only if its imaginary part is non-positive.
  1476. The following definition for (one-argument) arc tangent determines the
  1477. range and branch cuts:
  1478. @center @t{arctan} z = {{@t{log} (1+iz) - @t{log} (1-iz)}\over{2i}}
  1479. Beware of simplifying this formula; ``obvious'' simplifications are likely
  1480. to alter the branch cuts or the values on the branch cuts incorrectly.
  1481. The branch cut for the arc tangent function is in two pieces:
  1482. one along the positive imaginary axis above i
  1483. (exclusive), continuous with quadrant II, and one along the negative imaginary
  1484. axis below -i (exclusive), continuous with quadrant IV.
  1485. The points i and~-i are excluded from the domain.
  1486. The range is that strip of the complex plane containing numbers whose real
  1487. part is between -\pi/2 and~\pi/2. A number with real
  1488. part equal to -\pi/2 is in the range if and only if its imaginary
  1489. part is strictly positive; a number with real part equal to \pi/2 is in
  1490. the range if and only if its imaginary part is strictly negative. Thus the range of
  1491. arc tangent is identical to that of arc sine with the points
  1492. -\pi/2 and~\pi/2 excluded.
  1493. For @b{atan},
  1494. the signs of @i{number1} (indicated as @i{x})
  1495. and @i{number2} (indicated as @i{y}) are used to derive quadrant
  1496. information. Figure 12--14 details various special cases.
  1497. The asterisk (*) indicates that the entry in the figure applies to
  1498. implementations that support minus zero.
  1499. @group
  1500. @noindent
  1501. @w{ to 1pc{}@i{y} Condition @i{x} Condition Cartesian locus Range of result }
  1502. @w{ to 1pc{} y = 0 x > 0 Positive x-axis 0 }
  1503. @w{ to 1pc{*} y = +0 x > 0 Positive x-axis +0 }
  1504. @w{ to 1pc{*} y = -0 x > 0 Positive x-axis -0 }
  1505. @w{ to 1pc{} y > 0 x > 0 Quadrant I 0 < result < \pi/2 }
  1506. @w{ to 1pc{} y > 0 x = 0 Positive y-axis \pi/2 }
  1507. @w{ to 1pc{} y > 0 x < 0 Quadrant II \pi/2 < result < \pi }
  1508. @w{ to 1pc{} y = 0 x < 0 Negative x-axis \pi }
  1509. @w{ to 1pc{*} y = +0 x < 0 Negative x-axis +\pi }
  1510. @w{ to 1pc{*} y = -0 x < 0 Negative x-axis -\pi }
  1511. @w{ to 1pc{} y < 0 x < 0 Quadrant III -\pi < result < -\pi/2 }
  1512. @w{ to 1pc{} y < 0 x = 0 Negative y-axis -\pi/2 }
  1513. @w{ to 1pc{} y < 0 x > 0 Quadrant IV -\pi/2 < result < 0 }
  1514. @w{ to 1pc{} y = 0 x = 0 Origin undefined consequences }
  1515. @w{ to 1pc{*} y = +0 x = +0 Origin +0 }
  1516. @w{ to 1pc{*} y = -0 x = +0 Origin -0 }
  1517. @w{ to 1pc{*} y = +0 x = -0 Origin +\pi }
  1518. @w{ to 1pc{*} y = -0 x = -0 Origin -\pi }
  1519. @noindent
  1520. @w{ Figure 12--14: Quadrant information for arc tangent }
  1521. @end group
  1522. @subsubheading Examples::
  1523. @example
  1524. (asin 0) @result{} 0.0
  1525. (acos #c(0 1)) @result{} #C(1.5707963267948966 -0.8813735870195432)
  1526. (/ (atan 1 (sqrt 3)) 6) @result{} 0.087266
  1527. (atan #c(0 2)) @result{} #C(-1.5707964 0.54930615)
  1528. @end example
  1529. @subsubheading Exceptional Situations::
  1530. @b{acos} and @b{asin} should signal an error of @i{type} @b{type-error}
  1531. if @i{number} is not a @i{number}.
  1532. @b{atan} should signal @b{type-error} if
  1533. one argument is supplied and that argument is not a @i{number},
  1534. or if two arguments are supplied and both of those arguments are not @i{reals}.
  1535. @b{acos}, @b{asin}, and @b{atan} might signal @b{arithmetic-error}.
  1536. @subsubheading See Also::
  1537. @ref{log}
  1538. ,
  1539. @ref{sqrt; isqrt}
  1540. ,
  1541. @ref{Rule of Float Substitutability}
  1542. @subsubheading Notes::
  1543. The result of either @b{asin} or @b{acos} can be a @i{complex}
  1544. even if @i{number} is not a @i{complex}; this occurs when the
  1545. absolute value of @i{number} is greater than one.
  1546. @node pi, sinh, asin, Numbers Dictionary
  1547. @subsection pi [Constant Variable]
  1548. @subsubheading Value::
  1549. an @i{implementation-dependent} @i{long float}.
  1550. @subsubheading Description::
  1551. The best @i{long float} approximation to the mathematical constant \pi.
  1552. @subsubheading Examples::
  1553. @example
  1554. ;; In each of the following computations, the precision depends
  1555. ;; on the implementation. Also, if `long float' is treated by
  1556. ;; the implementation as equivalent to some other float format
  1557. ;; (e.g., `double float') the exponent marker might be the marker
  1558. ;; for that equivalent (e.g., `D' instead of `L').
  1559. pi @result{} 3.141592653589793L0
  1560. (cos pi) @result{} -1.0L0
  1561. (defun sin-of-degrees (degrees)
  1562. (let ((x (if (floatp degrees) degrees (float degrees pi))))
  1563. (sin (* x (/ (float pi x) 180)))))
  1564. @end example
  1565. @subsubheading Notes::
  1566. An approximation to \pi in some other precision can be obtained
  1567. by writing @t{(float pi x)}, where @t{x} is a @i{float} of the
  1568. desired precision, or by writing @t{(coerce pi @i{type})},
  1569. where @i{type} is the desired type, such as @b{short-float}.
  1570. @node sinh, *, pi, Numbers Dictionary
  1571. @subsection sinh, cosh, tanh, asinh, acosh, atanh [Function]
  1572. @code{sinh} @i{number} @result{} @i{result}
  1573. @code{cosh} @i{number} @result{} @i{result}
  1574. @code{tanh} @i{number} @result{} @i{result}
  1575. @code{asinh} @i{number} @result{} @i{result}
  1576. @code{acosh} @i{number} @result{} @i{result}
  1577. @code{atanh} @i{number} @result{} @i{result}
  1578. @subsubheading Arguments and Values::
  1579. @i{number}---a @i{number}.
  1580. @i{result}---a @i{number}.
  1581. @subsubheading Description::
  1582. These functions compute the hyperbolic sine, cosine, tangent,
  1583. arc sine, arc cosine, and arc tangent functions,
  1584. which are mathematically defined for an argument @i{x}
  1585. as given in Figure 12--15.
  1586. @group
  1587. @noindent
  1588. @w{ Function Definition }
  1589. @w{ Hyperbolic sine (e^x-e^{-x})/2 }
  1590. @w{ Hyperbolic cosine (e^x+e^{-x})/2 }
  1591. @w{ Hyperbolic tangent (e^x-e^{-x})/(e^x+e^{-x}) }
  1592. @w{ Hyperbolic arc sine @t{log} (x+\sqrt{1+x^2}) }
  1593. @w{ Hyperbolic arc cosine 2 @t{log} (\sqrt{(x+1)/2} + \sqrt{(x-1)/2}) }
  1594. @w{ Hyperbolic arc tangent (@t{log} (1+x) - @t{log} (1-x))/2 }
  1595. @noindent
  1596. @w{ Figure 12--15: Mathematical definitions for hyperbolic functions }
  1597. @end group
  1598. The following definition for the inverse hyperbolic cosine
  1599. determines the range and branch cuts:
  1600. @center @t{arccosh} z = 2 @t{log} (\sqrt{(z+1)/2} + \sqrt{(z-1)/2}\Bigr).
  1601. The branch cut for the inverse hyperbolic cosine function
  1602. lies along the real axis to the left of~1 (inclusive), extending
  1603. indefinitely along the negative real axis, continuous with quadrant II
  1604. and (between 0 and~1) with quadrant I.
  1605. The range is that half-strip of the complex plane containing numbers whose
  1606. real part is non-negative and whose imaginary
  1607. part is between -\pi (exclusive) and~\pi (inclusive).
  1608. A number with real part zero is in the range
  1609. if its imaginary part is between zero (inclusive) and~\pi (inclusive).
  1610. The following definition for the inverse hyperbolic sine determines
  1611. the range and branch cuts:
  1612. @center @t{arcsinh} z = @t{log} (z+\sqrt{1+z^2}\Bigr).
  1613. The branch cut for the inverse hyperbolic sine function is in two pieces:
  1614. one along the positive imaginary axis above i
  1615. (inclusive), continuous with quadrant I, and one along the negative imaginary
  1616. axis below -i (inclusive), continuous with quadrant III.
  1617. The range is that strip of the complex plane containing numbers whose imaginary
  1618. part is between -\pi/2 and~\pi/2. A number with imaginary
  1619. part equal to -\pi/2 is in the range if and only if its real
  1620. part is non-positive; a number with imaginary part equal to \pi/2 is in
  1621. the range if and only if its imaginary part is non-negative.
  1622. The following definition for the inverse hyperbolic tangent
  1623. determines the range and branch cuts:
  1624. @center @t{arctanh} z = {{@t{log} (1+z) - @t{log} (1-z)}\over{2}}.
  1625. Note that:
  1626. @center i @t{arctan} z = @t{arctanh} iz.
  1627. The branch cut for the inverse hyperbolic tangent function
  1628. is in two pieces: one along the negative real axis to the left of
  1629. -1 (inclusive), continuous with quadrant III, and one along
  1630. the positive real axis to the right of~1 (inclusive), continuous with
  1631. quadrant I. The points -1 and~1 are excluded from the
  1632. domain.
  1633. The range is that strip of the complex plane containing
  1634. numbers whose imaginary part is between -\pi/2 and
  1635. \pi/2. A number with imaginary part equal to -\pi/2
  1636. is in the range if and only if its real part is strictly negative; a number with
  1637. imaginary part equal to \pi/2 is in the range if and only if its imaginary
  1638. part is strictly positive.
  1639. Thus the range of the inverse hyperbolic tangent function is identical to
  1640. that of the inverse hyperbolic sine function with the points
  1641. -\pi i/2 and~\pi i/2 excluded.
  1642. @subsubheading Examples::
  1643. @example
  1644. (sinh 0) @result{} 0.0
  1645. (cosh (complex 0 -1)) @result{} #C(0.540302 -0.0)
  1646. @end example
  1647. @subsubheading Exceptional Situations::
  1648. Should signal an error of @i{type} @b{type-error}
  1649. if @i{number} is not a @i{number}.
  1650. Might signal @b{arithmetic-error}.
  1651. @subsubheading See Also::
  1652. @ref{log}
  1653. ,
  1654. @ref{sqrt; isqrt}
  1655. ,
  1656. @ref{Rule of Float Substitutability}
  1657. @subsubheading Notes::
  1658. The result of @b{acosh} may be a @i{complex} even if @i{number}
  1659. is not a @i{complex}; this occurs when @i{number} is less than one.
  1660. Also, the result of @b{atanh} may be a @i{complex} even if @i{number}
  1661. is not a @i{complex}; this occurs when the absolute value of @i{number}
  1662. is greater than one.
  1663. The branch cut formulae are mathematically correct, assuming
  1664. completely accurate computation.
  1665. Implementors should consult a good text on
  1666. numerical analysis. The formulae given above are not necessarily
  1667. the simplest ones for real-valued computations; they are chosen
  1668. to define the branch cuts in desirable ways for the complex case.
  1669. @node *, +, sinh, Numbers Dictionary
  1670. @subsection * [Function]
  1671. @code{*} @i{{&rest} numbers} @result{} @i{product}
  1672. @subsubheading Arguments and Values::
  1673. @i{number}---a @i{number}.
  1674. @i{product}---a @i{number}.
  1675. @subsubheading Description::
  1676. Returns the product of @i{numbers},
  1677. performing any necessary type conversions in the process.
  1678. If no @i{numbers} are supplied, @t{1} is returned.
  1679. @subsubheading Examples::
  1680. @example
  1681. (*) @result{} 1
  1682. (* 3 5) @result{} 15
  1683. (* 1.0 #c(22 33) 55/98) @result{} #C(12.346938775510203 18.520408163265305)
  1684. @end example
  1685. @subsubheading Exceptional Situations::
  1686. Might signal @b{type-error} if some @i{argument} is not a @i{number}.
  1687. Might signal @b{arithmetic-error}.
  1688. @subsubheading See Also::
  1689. @ref{Numeric Operations},
  1690. @ref{Rational Computations},
  1691. @ref{Floating-point Computations},
  1692. @ref{Complex Computations}
  1693. @node +, -, *, Numbers Dictionary
  1694. @subsection + [Function]
  1695. @code{+} @i{{&rest} numbers} @result{} @i{sum}
  1696. @subsubheading Arguments and Values::
  1697. @i{number}---a @i{number}.
  1698. @i{sum}---a @i{number}.
  1699. @subsubheading Description::
  1700. Returns the sum of @i{numbers},
  1701. performing any necessary type conversions in the process.
  1702. If no @i{numbers} are supplied, @t{0} is returned.
  1703. @subsubheading Examples::
  1704. @example
  1705. (+) @result{} 0
  1706. (+ 1) @result{} 1
  1707. (+ 31/100 69/100) @result{} 1
  1708. (+ 1/5 0.8) @result{} 1.0
  1709. @end example
  1710. @subsubheading Exceptional Situations::
  1711. Might signal @b{type-error} if some @i{argument} is not a @i{number}.
  1712. Might signal @b{arithmetic-error}.
  1713. @subsubheading See Also::
  1714. @ref{Numeric Operations},
  1715. @ref{Rational Computations},
  1716. @ref{Floating-point Computations},
  1717. @ref{Complex Computations}
  1718. @node -, /, +, Numbers Dictionary
  1719. @subsection - [Function]
  1720. @code{-} @i{number} @result{} @i{negation}
  1721. @code{-} @i{minuend {&rest} subtrahends^+} @result{} @i{difference}
  1722. @subsubheading Arguments and Values::
  1723. @i{number}, @i{minuend}, @i{subtrahend}---a @i{number}.
  1724. @i{negation}, @i{difference}---a @i{number}.
  1725. @subsubheading Description::
  1726. The @i{function} @b{-} performs arithmetic subtraction and negation.
  1727. If only one @i{number} is supplied,
  1728. the negation of that @i{number} is returned.
  1729. If more than one @i{argument} is given,
  1730. it subtracts all of the @i{subtrahends} from the @i{minuend}
  1731. and returns the result.
  1732. The @i{function} @b{-} performs necessary type conversions.
  1733. @subsubheading Examples::
  1734. @example
  1735. (- 55.55) @result{} -55.55
  1736. (- #c(3 -5)) @result{} #C(-3 5)
  1737. (- 0) @result{} 0
  1738. (eql (- 0.0) -0.0) @result{} @i{true}
  1739. (- #c(100 45) #c(0 45)) @result{} 100
  1740. (- 10 1 2 3 4) @result{} 0
  1741. @end example
  1742. @subsubheading Exceptional Situations::
  1743. Might signal @b{type-error} if some @i{argument} is not a @i{number}.
  1744. Might signal @b{arithmetic-error}.
  1745. @subsubheading See Also::
  1746. @ref{Numeric Operations},
  1747. @ref{Rational Computations},
  1748. @ref{Floating-point Computations},
  1749. @ref{Complex Computations}
  1750. @node /, 1+, -, Numbers Dictionary
  1751. @subsection / [Function]
  1752. @code{/} @i{number} @result{} @i{reciprocal}
  1753. @code{/} @i{numerator {&rest} denominators^+} @result{} @i{quotient}
  1754. @subsubheading Arguments and Values::
  1755. @i{number}, @i{denominator}---a non-zero @i{number}.
  1756. @i{numerator}, @i{quotient}, @i{reciprocal}---a @i{number}.
  1757. @subsubheading Description::
  1758. The @i{function} @b{/} performs division or reciprocation.
  1759. If no @i{denominators} are supplied,
  1760. the @i{function} @b{/} returns the reciprocal of @i{number}.
  1761. If at least one @i{denominator} is supplied,
  1762. the @i{function} @b{/} divides the @i{numerator} by all of the @i{denominators}
  1763. and returns the resulting @i{quotient}.
  1764. If each @i{argument} is either an @i{integer} or a @i{ratio},
  1765. and the result is not an @i{integer}, then it is a @i{ratio}.
  1766. The @i{function} @b{/} performs necessary type conversions.
  1767. If any @i{argument} is a @i{float} then
  1768. the rules of floating-point contagion apply;
  1769. see @ref{Floating-point Computations}.
  1770. @subsubheading Examples::
  1771. @example
  1772. (/ 12 4) @result{} 3
  1773. (/ 13 4) @result{} 13/4
  1774. (/ -8) @result{} -1/8
  1775. (/ 3 4 5) @result{} 3/20
  1776. (/ 0.5) @result{} 2.0
  1777. (/ 20 5) @result{} 4
  1778. (/ 5 20) @result{} 1/4
  1779. (/ 60 -2 3 5.0) @result{} -2.0
  1780. (/ 2 #c(2 2)) @result{} #C(1/2 -1/2)
  1781. @end example
  1782. @subsubheading Exceptional Situations::
  1783. The consequences are unspecified if any @i{argument} other than the first is zero.
  1784. If there is only one @i{argument}, the consequences are unspecified if it is zero.
  1785. Might signal @b{type-error} if some @i{argument} is not a @i{number}.
  1786. Might signal @b{division-by-zero} if division by zero is attempted.
  1787. Might signal @b{arithmetic-error}.
  1788. @subsubheading See Also::
  1789. @ref{floor; ffloor; ceiling; fceiling; truncate; ftruncate; round; fround}
  1790. , @b{ceiling}, @b{truncate}, @b{round}
  1791. @node 1+, abs, /, Numbers Dictionary
  1792. @subsection 1+, 1- [Function]
  1793. @code{1} @i{+} @result{} @i{number}
  1794. {successor}
  1795. @code{1} @i{-} @result{} @i{number}
  1796. {predecessor}
  1797. @subsubheading Arguments and Values::
  1798. @i{number}---a @i{number}.
  1799. @i{successor}, @i{predecessor}---a @i{number}.
  1800. @subsubheading Description::
  1801. @b{1+} returns a @i{number} that is one more than its argument @i{number}.
  1802. @b{1-} returns a @i{number} that is one less than its argument @i{number}.
  1803. @subsubheading Examples::
  1804. @example
  1805. (1+ 99) @result{} 100
  1806. (1- 100) @result{} 99
  1807. (1+ (complex 0.0)) @result{} #C(1.0 0.0)
  1808. (1- 5/3) @result{} 2/3
  1809. @end example
  1810. @subsubheading Exceptional Situations::
  1811. Might signal @b{type-error} if its @i{argument} is not a @i{number}.
  1812. Might signal @b{arithmetic-error}.
  1813. @subsubheading See Also::
  1814. @ref{incf; decf}
  1815. , @b{decf}
  1816. @subsubheading Notes::
  1817. @example
  1818. (1+ @i{number}) @equiv{} (+ @i{number} 1)
  1819. (1- @i{number}) @equiv{} (- @i{number} 1)
  1820. @end example
  1821. Implementors are encouraged to make the performance of both the previous
  1822. expressions be the same.
  1823. @node abs, evenp, 1+, Numbers Dictionary
  1824. @subsection abs [Function]
  1825. @code{abs} @i{number} @result{} @i{absolute-value}
  1826. @subsubheading Arguments and Values::
  1827. @i{number}---a @i{number}.
  1828. @i{absolute-value}---a non-negative @i{real}.
  1829. @subsubheading Description::
  1830. @b{abs} returns the absolute value of @i{number}.
  1831. If @i{number} is
  1832. a @i{real},
  1833. the result is of the same @i{type} as @i{number}.
  1834. If @i{number} is a @i{complex},
  1835. the result is a positive
  1836. @i{real}
  1837. with
  1838. the same magnitude as @i{number}.
  1839. The result can be a @i{float}
  1840. [Reviewer Note by Barmar: Single-float.]
  1841. even if @i{number}'s components are @i{rationals}
  1842. and an exact rational result
  1843. would have been possible.
  1844. Thus the result of @t{(abs #c(3 4))} can be either @t{5} or @t{5.0},
  1845. depending on the implementation.
  1846. @subsubheading Examples::
  1847. @example
  1848. (abs 0) @result{} 0
  1849. (abs 12/13) @result{} 12/13
  1850. (abs -1.09) @result{} 1.09
  1851. (abs #c(5.0 -5.0)) @result{} 7.071068
  1852. (abs #c(5 5)) @result{} 7.071068
  1853. (abs #c(3/5 4/5)) @result{} 1 or approximately 1.0
  1854. (eql (abs -0.0) -0.0) @result{} @i{true}
  1855. @end example
  1856. @subsubheading See Also::
  1857. @ref{Rule of Float Substitutability}
  1858. @subsubheading Notes::
  1859. If @i{number} is a @i{complex},
  1860. the result is equivalent to the following:
  1861. @t{(sqrt (+ (expt (realpart @i{number}) 2) (expt (imagpart @i{number}) 2)))}
  1862. An implementation should not use this formula directly
  1863. for all @i{complexes}
  1864. but should handle very large or very small components specially
  1865. to avoid intermediate overflow or underflow.
  1866. @node evenp, exp, abs, Numbers Dictionary
  1867. @subsection evenp, oddp [Function]
  1868. @code{evenp} @i{integer} @result{} @i{generalized-boolean}
  1869. @code{oddp} @i{integer} @result{} @i{generalized-boolean}
  1870. @subsubheading Arguments and Values::
  1871. @i{integer}---an @i{integer}.
  1872. @i{generalized-boolean}---a @i{generalized boolean}.
  1873. @subsubheading Description::
  1874. @b{evenp} returns @i{true} if @i{integer} is even (divisible by two);
  1875. otherwise, returns @i{false}.
  1876. @b{oddp} returns @i{true} if @i{integer} is odd (not divisible by two);
  1877. otherwise, returns @i{false}.
  1878. @subsubheading Examples::
  1879. @example
  1880. (evenp 0) @result{} @i{true}
  1881. (oddp 10000000000000000000000) @result{} @i{false}
  1882. (oddp -1) @result{} @i{true}
  1883. @end example
  1884. @subsubheading Exceptional Situations::
  1885. Should signal an error of @i{type} @b{type-error}
  1886. if @i{integer} is not an @i{integer}.
  1887. @subsubheading Notes::
  1888. @example
  1889. (evenp @i{integer}) @equiv{} (not (oddp @i{integer}))
  1890. (oddp @i{integer}) @equiv{} (not (evenp @i{integer}))
  1891. @end example
  1892. @node exp, gcd, evenp, Numbers Dictionary
  1893. @subsection exp, expt [Function]
  1894. @code{exp} @i{number} @result{} @i{result}
  1895. @code{expt} @i{base-number power-number} @result{} @i{result}
  1896. @subsubheading Arguments and Values::
  1897. @i{number}---a @i{number}.
  1898. @i{base-number}---a @i{number}.
  1899. @i{power-number}---a @i{number}.
  1900. @i{result}---a @i{number}.
  1901. @subsubheading Description::
  1902. @b{exp} and @b{expt} perform exponentiation.
  1903. @b{exp} returns @i{e} raised to the power @i{number},
  1904. where @i{e} is the base of the natural logarithms.
  1905. @b{exp} has no branch cut.
  1906. @b{expt} returns @i{base-number}
  1907. raised to the power @i{power-number}.
  1908. If the @i{base-number} is a @i{rational}
  1909. and @i{power-number} is
  1910. an @i{integer},
  1911. the calculation is exact and the result will be of @i{type} @b{rational};
  1912. otherwise a floating-point approximation might result.
  1913. For @b{expt} of a @i{complex rational} to an @i{integer} power,
  1914. the calculation must be exact and the result is
  1915. of type @t{(or rational (complex rational))}.
  1916. The result of @b{expt} can be a @i{complex},
  1917. even when neither argument is a @i{complex},
  1918. if @i{base-number} is negative and @i{power-number}
  1919. is not an @i{integer}.
  1920. The result is always the @i{principal} @i{complex} @i{value}.
  1921. For example, @t{(expt -8 1/3)} is not permitted to return @t{-2},
  1922. even though @t{-2} is one of the cube roots of @t{-8}.
  1923. The @i{principal} cube root is a @i{complex}
  1924. approximately equal to @t{#C(1.0 1.73205)}, not @t{-2}.
  1925. @b{expt} is defined
  1926. as @i{b^x = e^{x log b\/}}.
  1927. This defines the @i{principal} @i{values} precisely. The range of
  1928. @b{expt} is the entire complex plane. Regarded
  1929. as a function of @i{x}, with @i{b} fixed, there is no branch cut.
  1930. Regarded as a function of @i{b}, with @i{x} fixed, there is in general
  1931. a branch cut along the negative real axis, continuous with quadrant II.
  1932. The domain excludes the origin.
  1933. By definition, 0^0=1. If @i{b}=0 and the real part of @i{x} is strictly
  1934. positive, then
  1935. @i{b^x}=0. For all other values of @i{x}, 0^@i{x}
  1936. is an error.
  1937. When @i{power-number} is an @i{integer} @t{0},
  1938. then the result is always the value one in the @i{type}
  1939. of @i{base-number},
  1940. even if the @i{base-number} is zero (of any @i{type}). That is:
  1941. @example
  1942. (expt x 0) @equiv{} (coerce 1 (type-of x))
  1943. @end example
  1944. If @i{power-number} is a zero of any other @i{type},
  1945. then the result is also the value one, in the @i{type} of the arguments
  1946. after the application of the contagion rules in @ref{Contagion in Numeric Operations},
  1947. with one exception:
  1948. the consequences are undefined if @i{base-number} is zero when @i{power-number}
  1949. is zero and not of @i{type} @b{integer}.
  1950. @subsubheading Examples::
  1951. @example
  1952. (exp 0) @result{} 1.0
  1953. (exp 1) @result{} 2.718282
  1954. (exp (log 5)) @result{} 5.0
  1955. (expt 2 8) @result{} 256
  1956. (expt 4 .5) @result{} 2.0
  1957. (expt #c(0 1) 2) @result{} -1
  1958. (expt #c(2 2) 3) @result{} #C(-16 16)
  1959. (expt #c(2 2) 4) @result{} -64
  1960. @end example
  1961. @subsubheading See Also::
  1962. @ref{log}
  1963. ,
  1964. @ref{Rule of Float Substitutability}
  1965. @subsubheading Notes::
  1966. Implementations of @b{expt} are permitted to use different algorithms
  1967. for the cases of a @i{power-number} of @i{type} @b{rational}
  1968. and a @i{power-number} of @i{type} @b{float}.
  1969. Note that by the following logic,
  1970. @t{(sqrt (expt @i{x} 3))} is not equivalent to
  1971. @t{(expt @i{x} 3/2)}.
  1972. @example
  1973. (setq x (exp (/ (* 2 pi #c(0 1)) 3))) ;exp(2.pi.i/3)
  1974. (expt x 3) @result{} 1 ;except for round-off error
  1975. (sqrt (expt x 3)) @result{} 1 ;except for round-off error
  1976. (expt x 3/2) @result{} -1 ;except for round-off error
  1977. @end example
  1978. @node gcd, incf, exp, Numbers Dictionary
  1979. @subsection gcd [Function]
  1980. @code{gcd} @i{{&rest} integers} @result{} @i{greatest-common-denominator}
  1981. @subsubheading Arguments and Values::
  1982. @i{integer}---an @i{integer}.
  1983. @i{greatest-common-denominator}---a non-negative @i{integer}.
  1984. @subsubheading Description::
  1985. Returns the greatest common divisor of @i{integers}.
  1986. If only one @i{integer} is supplied, its absolute value is returned.
  1987. If no @i{integers} are given, @b{gcd} returns @t{0},
  1988. which is an identity for this operation.
  1989. @subsubheading Examples::
  1990. @example
  1991. (gcd) @result{} 0
  1992. (gcd 60 42) @result{} 6
  1993. (gcd 3333 -33 101) @result{} 1
  1994. (gcd 3333 -33 1002001) @result{} 11
  1995. (gcd 91 -49) @result{} 7
  1996. (gcd 63 -42 35) @result{} 7
  1997. (gcd 5) @result{} 5
  1998. (gcd -4) @result{} 4
  1999. @end example
  2000. @subsubheading Exceptional Situations::
  2001. Should signal an error of @i{type} @b{type-error}
  2002. if any @i{integer} is not an @i{integer}.
  2003. @subsubheading See Also::
  2004. @ref{lcm}
  2005. @subsubheading Notes::
  2006. For three or more arguments,
  2007. @example
  2008. (gcd b c ... z) @equiv{} (gcd (gcd a b) c ... z)
  2009. @end example
  2010. @node incf, lcm, gcd, Numbers Dictionary
  2011. @subsection incf, decf [Macro]
  2012. @code{incf} @i{place @r{[}delta-form@r{]}} @result{} @i{new-value}
  2013. @code{decf} @i{place @r{[}delta-form@r{]}} @result{} @i{new-value}
  2014. @subsubheading Arguments and Values::
  2015. @i{place}---a @i{place}.
  2016. @i{delta-form}---a @i{form}; evaluated to produce a @i{delta}.
  2017. The default is @t{1}.
  2018. @i{delta}---a @i{number}.
  2019. @i{new-value}---a @i{number}.
  2020. @subsubheading Description::
  2021. @b{incf} and @b{decf} are used for incrementing and
  2022. decrementing the @i{value} of @i{place}, respectively.
  2023. The @i{delta} is
  2024. added to (in the case of @b{incf})
  2025. or subtracted from (in the case of @b{decf})
  2026. the number in @i{place} and the result is stored in @i{place}.
  2027. Any necessary type conversions are performed automatically.
  2028. For information about the @i{evaluation} of @i{subforms} of @i{places},
  2029. see @ref{Evaluation of Subforms to Places}.
  2030. @subsubheading Examples::
  2031. @example
  2032. (setq n 0)
  2033. (incf n) @result{} 1
  2034. n @result{} 1
  2035. (decf n 3) @result{} -2
  2036. n @result{} -2
  2037. (decf n -5) @result{} 3
  2038. (decf n) @result{} 2
  2039. (incf n 0.5) @result{} 2.5
  2040. (decf n) @result{} 1.5
  2041. n @result{} 1.5
  2042. @end example
  2043. @subsubheading Side Effects::
  2044. @i{Place} is modified.
  2045. @subsubheading See Also::
  2046. @b{+},
  2047. @ref{-}
  2048. , @b{1+}, @b{1-},
  2049. @ref{setf; psetf}
  2050. @node lcm, log, incf, Numbers Dictionary
  2051. @subsection lcm [Function]
  2052. @code{lcm} @i{{&rest} integers} @result{} @i{least-common-multiple}
  2053. @subsubheading Arguments and Values::
  2054. @i{integer}---an @i{integer}.
  2055. @i{least-common-multiple}---a non-negative @i{integer}.
  2056. @subsubheading Description::
  2057. @b{lcm} returns the least common multiple of the @i{integers}.
  2058. If no @i{integer} is supplied, the @i{integer} @t{1} is returned.
  2059. If only one @i{integer} is supplied,
  2060. the absolute value of that @i{integer} is returned.
  2061. For two arguments that are not both zero,
  2062. @example
  2063. (lcm a b) @equiv{} (/ (abs (* a b)) (gcd a b))
  2064. @end example
  2065. If one or both arguments are zero,
  2066. @example
  2067. (lcm a 0) @equiv{} (lcm 0 a) @equiv{} 0
  2068. @end example
  2069. For three or more arguments,
  2070. @example
  2071. (lcm a b c ... z) @equiv{} (lcm (lcm a b) c ... z)
  2072. @end example
  2073. @subsubheading Examples::
  2074. @example
  2075. (lcm 10) @result{} 10
  2076. (lcm 25 30) @result{} 150
  2077. (lcm -24 18 10) @result{} 360
  2078. (lcm 14 35) @result{} 70
  2079. (lcm 0 5) @result{} 0
  2080. (lcm 1 2 3 4 5 6) @result{} 60
  2081. @end example
  2082. @subsubheading Exceptional Situations::
  2083. Should signal @b{type-error} if any argument is not an @i{integer}.
  2084. @subsubheading See Also::
  2085. @ref{gcd}
  2086. @node log, mod, lcm, Numbers Dictionary
  2087. @subsection log [Function]
  2088. @code{log} @i{number {&optional} base} @result{} @i{logarithm}
  2089. @subsubheading Arguments and Values::
  2090. @i{number}---a non-zero @i{number}.
  2091. @i{base}---a @i{number}.
  2092. @i{logarithm}---a @i{number}.
  2093. @subsubheading Description::
  2094. @b{log} returns the logarithm of @i{number} in base @i{base}.
  2095. If @i{base} is not supplied its value is @i{e},
  2096. the base of the natural logarithms.
  2097. @b{log} may return a @i{complex} when given a
  2098. @i{real}
  2099. negative @i{number}.
  2100. @example
  2101. (log -1.0) @equiv{} (complex 0.0 (float pi 0.0))
  2102. @end example
  2103. If @i{base} is zero,
  2104. @b{log} returns zero.
  2105. The result of @t{(log 8 2)} may be either @t{3} or @t{3.0}, depending on the
  2106. implementation. An implementation can use floating-point calculations
  2107. even if an exact integer result is possible.
  2108. The branch cut for the logarithm function of one argument (natural
  2109. logarithm) lies along the negative real axis, continuous with quadrant II.
  2110. The domain excludes the origin.
  2111. The mathematical definition of a complex logarithm
  2112. is as follows, whether or not minus zero is supported by the
  2113. implementation:
  2114. @example
  2115. (log @i{x}) @equiv{} (complex (log (abs @i{x})) (phase @i{x}))
  2116. @end example
  2117. Therefore the range of the one-argument logarithm function is that strip
  2118. of the complex plane containing numbers with imaginary parts between
  2119. -\pi (exclusive) and~\pi (inclusive) if minus zero is not supported,
  2120. or -\pi (inclusive) and~\pi (inclusive) if minus zero is supported.
  2121. The two-argument logarithm function is defined as
  2122. @example
  2123. (log @i{base} @i{number})
  2124. @equiv{} (/ (log @i{number}) (log @i{base}))
  2125. @end example
  2126. This defines the @i{principal} @i{values} precisely.
  2127. The range of the two-argument logarithm function is the entire complex plane.
  2128. @subsubheading Examples::
  2129. @example
  2130. (log 100 10)
  2131. @result{} 2.0
  2132. @result{} 2
  2133. (log 100.0 10) @result{} 2.0
  2134. (log #c(0 1) #c(0 -1))
  2135. @result{} #C(-1.0 0.0)
  2136. @i{OR}@result{} #C(-1 0)
  2137. (log 8.0 2) @result{} 3.0
  2138. @end example
  2139. @example
  2140. (log #c(-16 16) #c(2 2)) @result{} 3 or approximately #c(3.0 0.0)
  2141. or approximately 3.0 (unlikely)
  2142. @end example
  2143. @subsubheading Affected By::
  2144. The implementation.
  2145. @subsubheading See Also::
  2146. @ref{exp; expt}
  2147. ,
  2148. @b{expt},
  2149. @ref{Rule of Float Substitutability}
  2150. @node mod, signum, log, Numbers Dictionary
  2151. @subsection mod, rem [Function]
  2152. @code{mod} @i{number divisor} @result{} @i{modulus}
  2153. @code{rem} @i{number divisor} @result{} @i{remainder}
  2154. @subsubheading Arguments and Values::
  2155. @i{number}---a @i{real}.
  2156. @i{divisor}---a @i{real}.
  2157. @i{modulus}, @i{remainder}---a @i{real}.
  2158. @subsubheading Description::
  2159. @b{mod} and @b{rem} are generalizations of the modulus
  2160. and remainder functions respectively.
  2161. @b{mod} performs the operation @b{floor}
  2162. on @i{number} and @i{divisor}
  2163. and returns the remainder of the @b{floor} operation.
  2164. @b{rem} performs the operation @b{truncate}
  2165. on @i{number} and @i{divisor}
  2166. and returns the remainder of the @b{truncate} operation.
  2167. @b{mod} and @b{rem} are
  2168. the modulus and remainder functions
  2169. when @i{number} and @i{divisor} are @i{integers}.
  2170. @subsubheading Examples::
  2171. @example
  2172. (rem -1 5) @result{} -1
  2173. (mod -1 5) @result{} 4
  2174. (mod 13 4) @result{} 1
  2175. (rem 13 4) @result{} 1
  2176. (mod -13 4) @result{} 3
  2177. (rem -13 4) @result{} -1
  2178. (mod 13 -4) @result{} -3
  2179. (rem 13 -4) @result{} 1
  2180. (mod -13 -4) @result{} -1
  2181. (rem -13 -4) @result{} -1
  2182. (mod 13.4 1) @result{} 0.4
  2183. (rem 13.4 1) @result{} 0.4
  2184. (mod -13.4 1) @result{} 0.6
  2185. (rem -13.4 1) @result{} -0.4
  2186. @end example
  2187. @subsubheading See Also::
  2188. @ref{floor; ffloor; ceiling; fceiling; truncate; ftruncate; round; fround}
  2189. , @b{truncate}
  2190. @subsubheading Notes::
  2191. The result of @b{mod} is either zero or a
  2192. @i{real}
  2193. with the same sign as @i{divisor}.
  2194. @node signum, sqrt, mod, Numbers Dictionary
  2195. @subsection signum [Function]
  2196. @code{signum} @i{number} @result{} @i{signed-prototype}
  2197. @subsubheading Arguments and Values::
  2198. @i{number}---a @i{number}.
  2199. @i{signed-prototype}---a @i{number}.
  2200. @subsubheading Description::
  2201. @b{signum} determines a numerical value that indicates whether
  2202. @i{number} is negative, zero, or positive.
  2203. For a @i{rational},
  2204. @b{signum} returns one of @t{-1}, @t{0}, or @t{1}
  2205. according to whether @i{number} is negative, zero, or positive.
  2206. For a @i{float},
  2207. the result is a @i{float} of the same format
  2208. whose value is minus one, zero, or one.
  2209. For a @i{complex} number @t{z},
  2210. @t{(signum @i{z})} is a complex number of the same phase but with unit magnitude,
  2211. unless @t{z} is a complex zero, in which case the result is @t{z}.
  2212. For @i{rational} @i{arguments}, @b{signum} is a rational function,
  2213. but it may be irrational for @i{complex} @i{arguments}.
  2214. If @i{number} is a @i{float}, the result is a @i{float}.
  2215. If @i{number} is a @i{rational}, the result is a @i{rational}.
  2216. If @i{number} is a @i{complex float}, the result is a @i{complex float}.
  2217. If @i{number} is a @i{complex rational}, the result is a @i{complex},
  2218. but it is @i{implementation-dependent} whether that result is a
  2219. @i{complex rational} or a @i{complex float}.
  2220. @subsubheading Examples::
  2221. @example
  2222. (signum 0) @result{} 0
  2223. (signum 99) @result{} 1
  2224. (signum 4/5) @result{} 1
  2225. (signum -99/100) @result{} -1
  2226. (signum 0.0) @result{} 0.0
  2227. (signum #c(0 33)) @result{} #C(0.0 1.0)
  2228. (signum #c(7.5 10.0)) @result{} #C(0.6 0.8)
  2229. (signum #c(0.0 -14.7)) @result{} #C(0.0 -1.0)
  2230. (eql (signum -0.0) -0.0) @result{} @i{true}
  2231. @end example
  2232. @subsubheading See Also::
  2233. @ref{Rule of Float Substitutability}
  2234. @subsubheading Notes::
  2235. @example
  2236. (signum x) @equiv{} (if (zerop x) x (/ x (abs x)))
  2237. @end example
  2238. @node sqrt, random-state, signum, Numbers Dictionary
  2239. @subsection sqrt, isqrt [Function]
  2240. @code{sqrt} @i{number} @result{} @i{root}
  2241. @code{isqrt} @i{natural} @result{} @i{natural-root}
  2242. @subsubheading Arguments and Values::
  2243. @i{number}, @i{root}---a @i{number}.
  2244. @i{natural}, @i{natural-root}---a non-negative @i{integer}.
  2245. @subsubheading Description::
  2246. @b{sqrt} and @b{isqrt} compute square roots.
  2247. @b{sqrt} returns the @i{principal} square root of @i{number}.
  2248. If the @i{number} is not a @i{complex} but is negative,
  2249. then the result is a @i{complex}.
  2250. @b{isqrt} returns the greatest @i{integer}
  2251. less than or equal to the exact positive square root of @i{natural}.
  2252. If @i{number} is a positive @i{rational},
  2253. it is @i{implementation-dependent}
  2254. whether @i{root} is a @i{rational} or a @i{float}.
  2255. If @i{number} is a negative @i{rational},
  2256. it is @i{implementation-dependent}
  2257. whether @i{root} is a @i{complex rational} or a @i{complex float}.
  2258. The mathematical definition of complex square root (whether or not
  2259. minus zero is supported) follows:
  2260. @t{(sqrt @i{x}) = (exp (/ (log @i{x}) 2))}
  2261. The branch cut for square root lies along the negative real axis,
  2262. continuous with quadrant II.
  2263. The range consists of the right half-plane, including the non-negative
  2264. imaginary axis and excluding the negative imaginary axis.
  2265. @subsubheading Examples::
  2266. @example
  2267. (sqrt 9.0) @result{} 3.0
  2268. (sqrt -9.0) @result{} #C(0.0 3.0)
  2269. (isqrt 9) @result{} 3
  2270. (sqrt 12) @result{} 3.4641016
  2271. (isqrt 12) @result{} 3
  2272. (isqrt 300) @result{} 17
  2273. (isqrt 325) @result{} 18
  2274. (sqrt 25)
  2275. @result{} 5
  2276. @i{OR}@result{} 5.0
  2277. (isqrt 25) @result{} 5
  2278. (sqrt -1) @result{} #C(0.0 1.0)
  2279. (sqrt #c(0 2)) @result{} #C(1.0 1.0)
  2280. @end example
  2281. @subsubheading Exceptional Situations::
  2282. The @i{function} @b{sqrt} should signal @b{type-error} if its argument
  2283. is not a @i{number}.
  2284. The @i{function} @b{isqrt} should signal @b{type-error} if its argument
  2285. is not a non-negative @i{integer}.
  2286. The functions @b{sqrt} and @b{isqrt} might signal @b{arithmetic-error}.
  2287. @subsubheading See Also::
  2288. @ref{exp; expt}
  2289. ,
  2290. @ref{log}
  2291. ,
  2292. @ref{Rule of Float Substitutability}
  2293. @subsubheading Notes::
  2294. @example
  2295. (isqrt x) @equiv{} (values (floor (sqrt x)))
  2296. @end example
  2297. but it is potentially more efficient.
  2298. @node random-state, make-random-state, sqrt, Numbers Dictionary
  2299. @subsection random-state [System Class]
  2300. @subsubheading Class Precedence List::
  2301. @b{random-state},
  2302. @b{t}
  2303. @subsubheading Description::
  2304. A @i{random state} @i{object} contains state
  2305. information used by the pseudo-random number generator.
  2306. The nature of a @i{random state} @i{object} is @i{implementation-dependent}.
  2307. It can be printed out and successfully read back in by the same @i{implementation},
  2308. but might not function correctly as a @i{random state} in another @i{implementation}.
  2309. @i{Implementations} are required to provide a read syntax for
  2310. @i{objects} of @i{type} @b{random-state}, but the specific nature of that syntax
  2311. is @i{implementation-dependent}.
  2312. @subsubheading See Also::
  2313. @ref{random-state}
  2314. ,
  2315. @ref{random}
  2316. ,
  2317. @ref{Printing Random States}
  2318. @node make-random-state, random, random-state, Numbers Dictionary
  2319. @subsection make-random-state [Function]
  2320. @code{make-random-state} @i{{&optional} state} @result{} @i{new-state}
  2321. @subsubheading Arguments and Values::
  2322. @i{state}---a @i{random state}, or @b{nil}, or @b{t}.
  2323. The default is @b{nil}.
  2324. @i{new-state}---a @i{random state} @i{object}.
  2325. @subsubheading Description::
  2326. Creates a @i{fresh} @i{object} of @i{type} @b{random-state} suitable
  2327. for use as the @i{value} of @b{*random-state*}.
  2328. If @i{state} is a @i{random state} @i{object},
  2329. the @i{new-state} is a @i{copy}_5 of that @i{object}.
  2330. If @i{state} is @b{nil},
  2331. the @i{new-state} is a @i{copy}_5 of the @i{current random state}.
  2332. If @i{state} is @b{t},
  2333. the @i{new-state} is a @i{fresh} @i{random state} @i{object}
  2334. that has been randomly initialized by some means.
  2335. @subsubheading Examples::
  2336. @example
  2337. (let* ((rs1 (make-random-state nil))
  2338. (rs2 (make-random-state t))
  2339. (rs3 (make-random-state rs2))
  2340. (rs4 nil))
  2341. (list (loop for i from 1 to 10
  2342. collect (random 100)
  2343. when (= i 5)
  2344. do (setq rs4 (make-random-state)))
  2345. (loop for i from 1 to 10 collect (random 100 rs1))
  2346. (loop for i from 1 to 10 collect (random 100 rs2))
  2347. (loop for i from 1 to 10 collect (random 100 rs3))
  2348. (loop for i from 1 to 10 collect (random 100 rs4))))
  2349. @result{} ((29 25 72 57 55 68 24 35 54 65)
  2350. (29 25 72 57 55 68 24 35 54 65)
  2351. (93 85 53 99 58 62 2 23 23 59)
  2352. (93 85 53 99 58 62 2 23 23 59)
  2353. (68 24 35 54 65 54 55 50 59 49))
  2354. @end example
  2355. @subsubheading Exceptional Situations::
  2356. Should signal an error of @i{type} @b{type-error}
  2357. if @i{state} is not a @i{random state}, or @b{nil}, or @b{t}.
  2358. @subsubheading See Also::
  2359. @ref{random}
  2360. ,
  2361. @ref{random-state}
  2362. @subsubheading Notes::
  2363. One important use of @b{make-random-state} is to allow the same
  2364. series of pseudo-random @i{numbers} to be generated many times within a
  2365. single program.
  2366. @node random, random-state-p, make-random-state, Numbers Dictionary
  2367. @subsection random [Function]
  2368. @code{random} @i{limit {&optional} random-state} @result{} @i{random-number}
  2369. @subsubheading Arguments and Values::
  2370. @i{limit}---a positive @i{integer},
  2371. or a positive @i{float}.
  2372. @i{random-state}---a @i{random state}.
  2373. The default is the @i{current random state}.
  2374. @i{random-number}---a non-negative @i{number}
  2375. less than @i{limit}
  2376. and of the same @i{type} as @i{limit}.
  2377. @subsubheading Description::
  2378. Returns a pseudo-random number that is a non-negative @i{number}
  2379. less than @i{limit} and of the same @i{type} as @i{limit}.
  2380. The @i{random-state}, which is modified by this function,
  2381. encodes the internal state maintained by the random number generator.
  2382. An approximately uniform choice distribution is used. If @i{limit}
  2383. is an @i{integer}, each of the possible results occurs with
  2384. (approximate) probability 1/@i{limit}.
  2385. @subsubheading Examples::
  2386. @example
  2387. (<= 0 (random 1000) 1000) @result{} @i{true}
  2388. (let ((state1 (make-random-state))
  2389. (state2 (make-random-state)))
  2390. (= (random 1000 state1) (random 1000 state2))) @result{} @i{true}
  2391. @end example
  2392. @subsubheading Side Effects::
  2393. The @i{random-state} is modified.
  2394. @subsubheading Exceptional Situations::
  2395. Should signal an error of @i{type} @b{type-error}
  2396. if @i{limit} is not a positive @i{integer} or a positive @i{real}.
  2397. @subsubheading See Also::
  2398. @ref{make-random-state}
  2399. ,
  2400. @ref{random-state}
  2401. @subsubheading Notes::
  2402. See @i{Common Lisp: The Language} for information about generating random numbers.
  2403. @node random-state-p, *random-state*, random, Numbers Dictionary
  2404. @subsection random-state-p [Function]
  2405. @code{random-state-p} @i{object} @result{} @i{generalized-boolean}
  2406. @subsubheading Arguments and Values::
  2407. @i{object}---an @i{object}.
  2408. @i{generalized-boolean}---a @i{generalized boolean}.
  2409. @subsubheading Description::
  2410. Returns @i{true} if @i{object} is of @i{type} @b{random-state};
  2411. otherwise, returns @i{false}.
  2412. @subsubheading Examples::
  2413. @example
  2414. (random-state-p *random-state*) @result{} @i{true}
  2415. (random-state-p (make-random-state)) @result{} @i{true}
  2416. (random-state-p 'test-function) @result{} @i{false}
  2417. @end example
  2418. @subsubheading See Also::
  2419. @ref{make-random-state}
  2420. ,
  2421. @ref{random-state}
  2422. @subsubheading Notes::
  2423. @example
  2424. (random-state-p @i{object}) @equiv{} (typep @i{object} 'random-state)
  2425. @end example
  2426. @node *random-state*, numberp, random-state-p, Numbers Dictionary
  2427. @subsection *random-state* [Variable]
  2428. @subsubheading Value Type::
  2429. a @i{random state}.
  2430. @subsubheading Initial Value::
  2431. @i{implementation-dependent}.
  2432. @subsubheading Description::
  2433. The @i{current random state}, which is used, for example,
  2434. by the @i{function} @b{random} when a @i{random state} is not explicitly supplied.
  2435. @subsubheading Examples::
  2436. @example
  2437. (random-state-p *random-state*) @result{} @i{true}
  2438. (setq snap-shot (make-random-state))
  2439. ;; The series from any given point is random,
  2440. ;; but if you backtrack to that point, you get the same series.
  2441. (list (loop for i from 1 to 10 collect (random))
  2442. (let ((*random-state* snap-shot))
  2443. (loop for i from 1 to 10 collect (random)))
  2444. (loop for i from 1 to 10 collect (random))
  2445. (let ((*random-state* snap-shot))
  2446. (loop for i from 1 to 10 collect (random))))
  2447. @result{} ((19 16 44 19 96 15 76 96 13 61)
  2448. (19 16 44 19 96 15 76 96 13 61)
  2449. (16 67 0 43 70 79 58 5 63 50)
  2450. (16 67 0 43 70 79 58 5 63 50))
  2451. @end example
  2452. @subsubheading Affected By::
  2453. The @i{implementation}.
  2454. @b{random}.
  2455. @subsubheading See Also::
  2456. @ref{make-random-state}
  2457. ,
  2458. @ref{random}
  2459. ,
  2460. @b{random-state}
  2461. @subsubheading Notes::
  2462. @i{Binding} @b{*random-state*} to a different
  2463. @i{random state} @i{object} correctly saves and
  2464. restores the old @i{random state} @i{object}.
  2465. @node numberp, cis, *random-state*, Numbers Dictionary
  2466. @subsection numberp [Function]
  2467. @code{numberp} @i{object} @result{} @i{generalized-boolean}
  2468. @subsubheading Arguments and Values::
  2469. @i{object}---an @i{object}.
  2470. @i{generalized-boolean}---a @i{generalized boolean}.
  2471. @subsubheading Description::
  2472. Returns @i{true} if @i{object} is of @i{type} @b{number};
  2473. otherwise, returns @i{false}.
  2474. @subsubheading Examples::
  2475. @example
  2476. (numberp 12) @result{} @i{true}
  2477. (numberp (expt 2 130)) @result{} @i{true}
  2478. (numberp #c(5/3 7.2)) @result{} @i{true}
  2479. (numberp nil) @result{} @i{false}
  2480. (numberp (cons 1 2)) @result{} @i{false}
  2481. @end example
  2482. @subsubheading Notes::
  2483. @example
  2484. (numberp @i{object}) @equiv{} (typep @i{object} 'number)
  2485. @end example
  2486. @node cis, complex, numberp, Numbers Dictionary
  2487. @subsection cis [Function]
  2488. @code{cis} @i{radians} @result{} @i{number}
  2489. @subsubheading Arguments and Values::
  2490. @i{radians}---a @i{real}.
  2491. @i{number}---a @i{complex}.
  2492. @subsubheading Description::
  2493. @b{cis} returns the value of~@i{e}^{i\cdot @i{radians}},
  2494. which is a @i{complex} in which the
  2495. real part is equal to the cosine of @i{radians}, and the
  2496. imaginary part is equal to the sine of @i{radians}.
  2497. @subsubheading Examples::
  2498. @example
  2499. (cis 0) @result{} #C(1.0 0.0)
  2500. @end example
  2501. @subsubheading See Also::
  2502. @ref{Rule of Float Substitutability}
  2503. @node complex, complexp, cis, Numbers Dictionary
  2504. @subsection complex [Function]
  2505. @code{complex} @i{realpart {&optional} imagpart} @result{} @i{complex}
  2506. @subsubheading Arguments and Values::
  2507. @i{realpart}---a @i{real}.
  2508. @i{imagpart}---a @i{real}.
  2509. @i{complex}---a @i{rational} or a @i{complex}.
  2510. @subsubheading Description::
  2511. @b{complex} returns a @i{number}
  2512. whose real part is @i{realpart}
  2513. and whose imaginary part is @i{imagpart}.
  2514. If @i{realpart} is a @i{rational}
  2515. and @i{imagpart} is the @i{rational} number zero,
  2516. the result of @b{complex} is @i{realpart}, a @i{rational}.
  2517. Otherwise, the result is a @i{complex}.
  2518. If either @i{realpart} or @i{imagpart} is a @i{float},
  2519. the non-@i{float} is converted to a @i{float}
  2520. before the @i{complex} is created.
  2521. If @i{imagpart} is not supplied, the imaginary part is a
  2522. zero of the same @i{type} as @i{realpart}; @i{i.e.}, @t{(coerce 0 (type-of @i{realpart}))} is
  2523. effectively used.
  2524. Type upgrading implies a movement upwards in the type
  2525. hierarchy lattice.
  2526. In the case of @i{complexes}, the @i{type-specifier}
  2527. [Reviewer Note by Barmar: What type specifier?]
  2528. must be a subtype of
  2529. @t{(upgraded-complex-part-type @i{type-specifier})}.
  2530. If @i{type-specifier1} is a subtype of @i{type-specifier2}, then
  2531. @t{(upgraded-complex-element-type '@i{type-specifier1})}
  2532. must also be a subtype of
  2533. @t{(upgraded-complex-element-type '@i{type-specifier2})}.
  2534. Two disjoint types can be upgraded into
  2535. the same thing.
  2536. @subsubheading Examples::
  2537. @example
  2538. (complex 0) @result{} 0
  2539. (complex 0.0) @result{} #C(0.0 0.0)
  2540. (complex 1 1/2) @result{} #C(1 1/2)
  2541. (complex 1 .99) @result{} #C(1.0 0.99)
  2542. (complex 3/2 0.0) @result{} #C(1.5 0.0)
  2543. @end example
  2544. @subsubheading See Also::
  2545. @ref{realpart; imagpart}
  2546. , @b{imagpart}
  2547. @subsubheading Notes::
  2548. @example
  2549. #c(a b) @equiv{} #.(complex a b)
  2550. @end example
  2551. @node complexp, conjugate, complex, Numbers Dictionary
  2552. @subsection complexp [Function]
  2553. @code{complexp} @i{object} @result{} @i{generalized-boolean}
  2554. @subsubheading Arguments and Values::
  2555. @i{object}---an @i{object}.
  2556. @i{generalized-boolean}---a @i{generalized boolean}.
  2557. @subsubheading Description::
  2558. Returns @i{true} if @i{object} is of @i{type} @b{complex};
  2559. otherwise, returns @i{false}.
  2560. @subsubheading Examples::
  2561. @example
  2562. (complexp 1.2d2) @result{} @i{false}
  2563. (complexp #c(5/3 7.2)) @result{} @i{true}
  2564. @end example
  2565. @subsubheading See Also::
  2566. @ref{complex}
  2567. (@i{function} and @i{type}),
  2568. @ref{typep}
  2569. @subsubheading Notes::
  2570. @example
  2571. (complexp @i{object}) @equiv{} (typep @i{object} 'complex)
  2572. @end example
  2573. @node conjugate, phase, complexp, Numbers Dictionary
  2574. @subsection conjugate [Function]
  2575. @code{conjugate} @i{number} @result{} @i{conjugate}
  2576. @subsubheading Arguments and Values::
  2577. @i{number}---a @i{number}.
  2578. @i{conjugate}---a @i{number}.
  2579. @subsubheading Description::
  2580. Returns the complex conjugate of @i{number}.
  2581. The conjugate of a
  2582. @i{real}
  2583. number is itself.
  2584. @subsubheading Examples::
  2585. @example
  2586. (conjugate #c(0 -1)) @result{} #C(0 1)
  2587. (conjugate #c(1 1)) @result{} #C(1 -1)
  2588. (conjugate 1.5) @result{} 1.5
  2589. (conjugate #C(3/5 4/5)) @result{} #C(3/5 -4/5)
  2590. (conjugate #C(0.0D0 -1.0D0)) @result{} #C(0.0D0 1.0D0)
  2591. (conjugate 3.7) @result{} 3.7
  2592. @end example
  2593. @subsubheading Notes::
  2594. For a @i{complex} number @t{z},
  2595. @example
  2596. (conjugate z) @equiv{} (complex (realpart z) (- (imagpart z)))
  2597. @end example
  2598. @node phase, realpart, conjugate, Numbers Dictionary
  2599. @subsection phase [Function]
  2600. @code{phase} @i{number} @result{} @i{phase}
  2601. @subsubheading Arguments and Values::
  2602. @i{number}---a @i{number}.
  2603. @i{phase}---a @i{number}.
  2604. @subsubheading Description::
  2605. @b{phase}
  2606. returns the phase
  2607. of @i{number} (the angle part of its polar representation)
  2608. in radians, in the range
  2609. -\pi (exclusive) if minus zero is not supported, or
  2610. -\pi (inclusive) if minus zero is supported,
  2611. to \pi (inclusive). The phase of a positive
  2612. @i{real}
  2613. number
  2614. is zero; that of a negative
  2615. @i{real}
  2616. number is \pi.
  2617. The phase of zero is defined to be zero.
  2618. If @i{number} is a @i{complex float},
  2619. the result is a @i{float} of the same @i{type}
  2620. as the components of @i{number}.
  2621. If @i{number} is a @i{float}, the result is a
  2622. @i{float} of the same @i{type}.
  2623. If @i{number} is a @i{rational} or a @i{complex rational},
  2624. the result is a @i{single float}.
  2625. The branch cut for @b{phase} lies along the negative real
  2626. axis, continuous with quadrant II. The range consists of that portion of
  2627. the real axis between -\pi (exclusive) and~\pi (inclusive).
  2628. The mathematical definition of @b{phase} is as follows:
  2629. @t{(phase @i{x}) = (atan (imagpart @i{x}) (realpart @i{x}))}
  2630. @subsubheading Examples::
  2631. @example
  2632. (phase 1) @result{} 0.0s0
  2633. (phase 0) @result{} 0.0s0
  2634. (phase (cis 30)) @result{} -1.4159266
  2635. (phase #c(0 1)) @result{} 1.5707964
  2636. @end example
  2637. @subsubheading Exceptional Situations::
  2638. Should signal @b{type-error} if its argument is not a @i{number}.
  2639. Might signal @b{arithmetic-error}.
  2640. @subsubheading See Also::
  2641. @ref{Rule of Float Substitutability}
  2642. @node realpart, upgraded-complex-part-type, phase, Numbers Dictionary
  2643. @subsection realpart, imagpart [Function]
  2644. @code{realpart} @i{number} @result{} @i{real}
  2645. @code{imagpart} @i{number} @result{} @i{real}
  2646. @subsubheading Arguments and Values::
  2647. @i{number}---a @i{number}.
  2648. @i{real}---a @i{real}.
  2649. @subsubheading Description::
  2650. @b{realpart} and @b{imagpart} return the real and
  2651. imaginary parts of @i{number} respectively.
  2652. If @i{number} is
  2653. @i{real},
  2654. then @b{realpart} returns @i{number} and @b{imagpart}
  2655. returns @t{(* 0 @i{number})}, which has the effect that the
  2656. imaginary part of a @i{rational} is @t{0} and that of
  2657. a @i{float} is a floating-point zero of the same format.
  2658. @subsubheading Examples::
  2659. @example
  2660. (realpart #c(23 41)) @result{} 23
  2661. (imagpart #c(23 41.0)) @result{} 41.0
  2662. (realpart #c(23 41.0)) @result{} 23.0
  2663. (imagpart 23.0) @result{} 0.0
  2664. @end example
  2665. @subsubheading Exceptional Situations::
  2666. Should signal an error of @i{type} @b{type-error}
  2667. if @i{number} is not a @i{number}.
  2668. @subsubheading See Also::
  2669. @ref{complex}
  2670. @node upgraded-complex-part-type, realp, realpart, Numbers Dictionary
  2671. @subsection upgraded-complex-part-type [Function]
  2672. @code{upgraded-complex-part-type} @i{typespec {&optional} environment} @result{} @i{upgraded-typespec}
  2673. @subsubheading Arguments and Values::
  2674. @i{typespec}---a @i{type specifier}.
  2675. @i{environment}---an @i{environment} @i{object}.
  2676. The default is @b{nil}, denoting the @i{null lexical environment}
  2677. and the and current @i{global environment}.
  2678. @i{upgraded-typespec}---a @i{type specifier}.
  2679. @subsubheading Description::
  2680. @b{upgraded-complex-part-type} returns the part type of the
  2681. most specialized @i{complex} number representation that can
  2682. hold parts of @i{type} @i{typespec}.
  2683. The @i{typespec} is a @i{subtype} of
  2684. (and possibly @i{type equivalent} to)
  2685. the @i{upgraded-typespec}.
  2686. The purpose of @b{upgraded-complex-part-type}
  2687. is to reveal how an implementation does its @i{upgrading}.
  2688. @subsubheading See Also::
  2689. @ref{complex}
  2690. (@i{function} and @i{type})
  2691. @subsubheading Notes::
  2692. @node realp, numerator, upgraded-complex-part-type, Numbers Dictionary
  2693. @subsection realp [Function]
  2694. @code{realp} @i{object} @result{} @i{generalized-boolean}
  2695. @subsubheading Arguments and Values::
  2696. @i{object}---an @i{object}.
  2697. @i{generalized-boolean}---a @i{generalized boolean}.
  2698. @subsubheading Description::
  2699. Returns @i{true} if @i{object} is of @i{type} @b{real};
  2700. otherwise, returns @i{false}.
  2701. @subsubheading Examples::
  2702. @example
  2703. (realp 12) @result{} @i{true}
  2704. (realp #c(5/3 7.2)) @result{} @i{false}
  2705. (realp nil) @result{} @i{false}
  2706. (realp (cons 1 2)) @result{} @i{false}
  2707. @end example
  2708. @subsubheading Notes::
  2709. @example
  2710. (realp @i{object}) @equiv{} (typep @i{object} 'real)
  2711. @end example
  2712. @node numerator, rational, realp, Numbers Dictionary
  2713. @subsection numerator, denominator [Function]
  2714. @code{numerator} @i{rational} @result{} @i{numerator}
  2715. @code{denominator} @i{rational} @result{} @i{denominator}
  2716. @subsubheading Arguments and Values::
  2717. @i{rational}---a @i{rational}.
  2718. @i{numerator}---an @i{integer}.
  2719. @i{denominator}---a positive @i{integer}.
  2720. @subsubheading Description::
  2721. @b{numerator} and @b{denominator} reduce @i{rational}
  2722. to canonical form and compute the numerator or denominator of that number.
  2723. @b{numerator} and @b{denominator} return the numerator
  2724. or denominator of the canonical form of @i{rational}.
  2725. If @i{rational} is an @i{integer},
  2726. @b{numerator} returns @i{rational}
  2727. and @b{denominator} returns 1.
  2728. @subsubheading Examples::
  2729. @example
  2730. (numerator 1/2) @result{} 1
  2731. (denominator 12/36) @result{} 3
  2732. (numerator -1) @result{} -1
  2733. (denominator (/ -33)) @result{} 33
  2734. (numerator (/ 8 -6)) @result{} -4
  2735. (denominator (/ 8 -6)) @result{} 3
  2736. @end example
  2737. @subsubheading See Also::
  2738. @ref{/}
  2739. @subsubheading Notes::
  2740. @example
  2741. (gcd (numerator x) (denominator x)) @result{} 1
  2742. @end example
  2743. @node rational, rationalp, numerator, Numbers Dictionary
  2744. @subsection rational, rationalize [Function]
  2745. @code{rational} @i{number} @result{} @i{rational}
  2746. @code{rationalize} @i{number} @result{} @i{rational}
  2747. @subsubheading Arguments and Values::
  2748. @i{number}---a @i{real}.
  2749. @i{rational}---a @i{rational}.
  2750. @subsubheading Description::
  2751. @b{rational} and @b{rationalize} convert
  2752. @i{reals}
  2753. to @i{rationals}.
  2754. If @i{number} is already @i{rational}, it is returned.
  2755. If @i{number} is a @i{float},
  2756. @b{rational} returns a @i{rational}
  2757. that is mathematically equal in value to the @i{float}.
  2758. @b{rationalize} returns a @i{rational} that
  2759. approximates the @i{float} to the accuracy of
  2760. the underlying floating-point representation.
  2761. @b{rational} assumes that the @i{float} is completely accurate.
  2762. @b{rationalize} assumes that the
  2763. @i{float} is accurate only to the precision of the
  2764. floating-point representation.
  2765. @subsubheading Examples::
  2766. @example
  2767. (rational 0) @result{} 0
  2768. (rationalize -11/100) @result{} -11/100
  2769. (rational .1) @result{} 13421773/134217728 ;implementation-dependent
  2770. (rationalize .1) @result{} 1/10
  2771. @end example
  2772. @subsubheading Affected By::
  2773. The @i{implementation}.
  2774. @subsubheading Exceptional Situations::
  2775. Should signal an error of @i{type} @b{type-error}
  2776. if @i{number} is not a @i{real}.
  2777. Might signal @b{arithmetic-error}.
  2778. @subsubheading Notes::
  2779. It is always the case that
  2780. @example
  2781. (float (rational x) x) @equiv{} x
  2782. @end example
  2783. and
  2784. @example
  2785. (float (rationalize x) x) @equiv{} x
  2786. @end example
  2787. That is, rationalizing a @i{float} by either method
  2788. and then converting it back
  2789. to a @i{float}
  2790. of the same format produces the original @i{number}.
  2791. @node rationalp, ash, rational, Numbers Dictionary
  2792. @subsection rationalp [Function]
  2793. @code{rationalp} @i{object} @result{} @i{generalized-boolean}
  2794. @subsubheading Arguments and Values::
  2795. @i{object}---an @i{object}.
  2796. @i{generalized-boolean}---a @i{generalized boolean}.
  2797. @subsubheading Description::
  2798. Returns @i{true} if @i{object} is of @i{type} @b{rational};
  2799. otherwise, returns @i{false}.
  2800. @subsubheading Examples::
  2801. @example
  2802. (rationalp 12) @result{} @i{true}
  2803. (rationalp 6/5) @result{} @i{true}
  2804. (rationalp 1.212) @result{} @i{false}
  2805. @end example
  2806. @subsubheading See Also::
  2807. @ref{rational}
  2808. @subsubheading Notes::
  2809. @example
  2810. (rationalp @i{object}) @equiv{} (typep @i{object} 'rational)
  2811. @end example
  2812. @node ash, integer-length, rationalp, Numbers Dictionary
  2813. @subsection ash [Function]
  2814. @code{ash} @i{integer count} @result{} @i{shifted-integer}
  2815. @subsubheading Arguments and Values::
  2816. @i{integer}---an @i{integer}.
  2817. @i{count}---an @i{integer}.
  2818. @i{shifted-integer}---an @i{integer}.
  2819. @subsubheading Description::
  2820. @b{ash} performs the arithmetic shift operation on the binary
  2821. representation of @i{integer}, which is treated as if it were binary.
  2822. @b{ash} shifts @i{integer} arithmetically left by @i{count} bit
  2823. positions if @i{count} is positive,
  2824. or right @i{count} bit positions if @i{count} is negative.
  2825. The shifted value of the same sign
  2826. as @i{integer} is returned.
  2827. Mathematically speaking, @b{ash} performs the computation
  2828. @t{floor}(@i{integer}{\cdot} 2^@i{count}).
  2829. Logically, @b{ash}
  2830. moves all of the bits in @i{integer} to the left,
  2831. adding zero-bits at the right, or moves them to the right,
  2832. discarding bits.
  2833. @b{ash} is defined to behave as if @i{integer} were
  2834. represented in two's complement form, regardless of
  2835. how @i{integers} are represented internally.
  2836. @subsubheading Examples::
  2837. @example
  2838. (ash 16 1) @result{} 32
  2839. (ash 16 0) @result{} 16
  2840. (ash 16 -1) @result{} 8
  2841. (ash -100000000000000000000000000000000 -100) @result{} -79
  2842. @end example
  2843. @subsubheading Exceptional Situations::
  2844. Should signal an error of @i{type} @b{type-error}
  2845. if @i{integer} is not an @i{integer}.
  2846. Should signal an error of @i{type} @b{type-error}
  2847. if @i{count} is not an @i{integer}.
  2848. Might signal @b{arithmetic-error}.
  2849. @subsubheading Notes::
  2850. @example
  2851. (logbitp @i{j} (ash @i{n} @i{k}))
  2852. @equiv{} (and (>= @i{j} @i{k}) (logbitp (- @i{j} @i{k}) @i{n}))
  2853. @end example
  2854. @node integer-length, integerp, ash, Numbers Dictionary
  2855. @subsection integer-length [Function]
  2856. @code{integer-length} @i{integer} @result{} @i{number-of-bits}
  2857. @subsubheading Arguments and Values::
  2858. @i{integer}---an @i{integer}.
  2859. @i{number-of-bits}---a non-negative @i{integer}.
  2860. @subsubheading Description::
  2861. Returns the number of bits needed to represent @i{integer}
  2862. in binary two's-complement format.
  2863. @subsubheading Examples::
  2864. @example
  2865. (integer-length 0) @result{} 0
  2866. (integer-length 1) @result{} 1
  2867. (integer-length 3) @result{} 2
  2868. (integer-length 4) @result{} 3
  2869. (integer-length 7) @result{} 3
  2870. (integer-length -1) @result{} 0
  2871. (integer-length -4) @result{} 2
  2872. (integer-length -7) @result{} 3
  2873. (integer-length -8) @result{} 3
  2874. (integer-length (expt 2 9)) @result{} 10
  2875. (integer-length (1- (expt 2 9))) @result{} 9
  2876. (integer-length (- (expt 2 9))) @result{} 9
  2877. (integer-length (- (1+ (expt 2 9)))) @result{} 10
  2878. @end example
  2879. @subsubheading Exceptional Situations::
  2880. Should signal an error of @i{type} @b{type-error}
  2881. if @i{integer} is not an @i{integer}.
  2882. @subsubheading Notes::
  2883. This function could have been defined by:
  2884. @example
  2885. (defun integer-length (integer)
  2886. (ceiling (log (if (minusp integer)
  2887. (- integer)
  2888. (1+ integer))
  2889. 2)))
  2890. @end example
  2891. If @i{integer} is non-negative, then its value can be represented
  2892. in unsigned binary form in a field whose width in bits is
  2893. no smaller than @t{(integer-length @i{integer})}.
  2894. Regardless of the sign of @i{integer}, its value can be
  2895. represented in signed binary two's-complement form in a field
  2896. whose width in bits is no smaller than @t{(+ (integer-length @i{integer}) 1)}.
  2897. @node integerp, parse-integer, integer-length, Numbers Dictionary
  2898. @subsection integerp [Function]
  2899. @code{integerp} @i{object} @result{} @i{generalized-boolean}
  2900. @subsubheading Arguments and Values::
  2901. @i{object}---an @i{object}.
  2902. @i{generalized-boolean}---a @i{generalized boolean}.
  2903. @subsubheading Description::
  2904. Returns @i{true} if @i{object} is of @i{type} @b{integer};
  2905. otherwise, returns @i{false}.
  2906. @subsubheading Examples::
  2907. @example
  2908. (integerp 1) @result{} @i{true}
  2909. (integerp (expt 2 130)) @result{} @i{true}
  2910. (integerp 6/5) @result{} @i{false}
  2911. (integerp nil) @result{} @i{false}
  2912. @end example
  2913. @subsubheading Notes::
  2914. @example
  2915. (integerp @i{object}) @equiv{} (typep @i{object} 'integer)
  2916. @end example
  2917. @node parse-integer, boole, integerp, Numbers Dictionary
  2918. @subsection parse-integer [Function]
  2919. @code{parse-integer} @i{string {&key} start end radix junk-allowed} @result{} @i{integer, pos}
  2920. @subsubheading Arguments and Values::
  2921. @i{string}---a @i{string}.
  2922. @i{start}, @i{end}---@i{bounding index designators} of @i{string}.
  2923. The defaults for @i{start} and @i{end} are @t{0} and @b{nil}, respectively.
  2924. @i{radix}---a @i{radix}.
  2925. The default is @t{10}.
  2926. @i{junk-allowed}---a @i{generalized boolean}.
  2927. The default is @i{false}.
  2928. @i{integer}---an @i{integer} or @i{false}.
  2929. @i{pos}---a @i{bounding index} of @i{string}.
  2930. @subsubheading Description::
  2931. @b{parse-integer} parses an @i{integer} in the specified @i{radix}
  2932. from the substring of @i{string} delimited by @i{start} and @i{end}.
  2933. @b{parse-integer} expects an optional sign (@t{+} or @t{-}) followed by
  2934. a a non-empty sequence of digits to be interpreted in the specified @i{radix}.
  2935. Optional leading and trailing @i{whitespace}_1 is ignored.
  2936. @b{parse-integer} does not recognize the syntactic radix-specifier
  2937. prefixes @t{#O}, @t{#B}, @t{#X}, and @t{#@i{n}R},
  2938. nor does it recognize a trailing decimal point.
  2939. If @i{junk-allowed} is @i{false}, an error of @i{type} @b{parse-error} is
  2940. signaled if substring does not consist entirely of the representation of a
  2941. signed @i{integer}, possibly surrounded on either side by @i{whitespace}_1
  2942. @i{characters}.
  2943. The first @i{value} returned is either
  2944. the @i{integer} that was parsed,
  2945. or else @b{nil} if no syntactically correct @i{integer}
  2946. was seen but @i{junk-allowed} was @i{true}.
  2947. The second @i{value} is either
  2948. the index into the @i{string} of the delimiter that terminated the parse,
  2949. or the upper @i{bounding index} of the substring if the parse terminated at
  2950. the end of the substring (as is always the case if @i{junk-allowed}
  2951. is @i{false}).
  2952. @subsubheading Examples::
  2953. @example
  2954. (parse-integer "123") @result{} 123, 3
  2955. (parse-integer "123" :start 1 :radix 5) @result{} 13, 3
  2956. (parse-integer "no-integer" :junk-allowed t) @result{} NIL, 0
  2957. @end example
  2958. @subsubheading Exceptional Situations::
  2959. If @i{junk-allowed} is @i{false},
  2960. an error is signaled if substring does not consist entirely of
  2961. the representation of an @i{integer},
  2962. possibly surrounded on either side by
  2963. @i{whitespace}_1 characters.
  2964. @node boole, boole-1, parse-integer, Numbers Dictionary
  2965. @subsection boole [Function]
  2966. @code{boole} @i{op integer-1 integer-2} @result{} @i{result-integer}
  2967. @subsubheading Arguments and Values::
  2968. @i{Op}---a @i{bit-wise logical operation specifier}.
  2969. @i{integer-1}---an @i{integer}.
  2970. @i{integer-2}---an @i{integer}.
  2971. @i{result-integer}---an @i{integer}.
  2972. @subsubheading Description::
  2973. @b{boole} performs bit-wise logical operations on
  2974. @i{integer-1} and @i{integer-2}, which are treated as if
  2975. they were binary and in two's complement representation.
  2976. The operation to be performed and the return value are determined by
  2977. @i{op}.
  2978. @b{boole} returns the values
  2979. specified for any @i{op} in Figure 12--16.
  2980. {
  2981. @group
  2982. @noindent
  2983. @w{ Op Result }
  2984. @w{ @b{boole-1} @i{integer-1} }
  2985. @w{ @b{boole-2} @i{integer-2} }
  2986. @w{ @b{boole-andc1} and complement of @i{integer-1} with @i{integer-2} }
  2987. @w{ @b{boole-andc2} and @i{integer-1} with complement of @i{integer-2} }
  2988. @w{ @b{boole-and} and }
  2989. @w{ @b{boole-c1} complement of @i{integer-1} }
  2990. @w{ @b{boole-c2} complement of @i{integer-2} }
  2991. @w{ @b{boole-clr} always 0 (all zero bits) }
  2992. @w{ @b{boole-eqv} equivalence (exclusive nor) }
  2993. @w{ @b{boole-ior} inclusive or }
  2994. @w{ @b{boole-nand} not-and }
  2995. @w{ @b{boole-nor} not-or }
  2996. @w{ @b{boole-orc1} or complement of @i{integer-1} with @i{integer-2} }
  2997. @w{ @b{boole-orc2} or @i{integer-1} with complement of @i{integer-2} }
  2998. @w{ @b{boole-set} always -1 (all one bits) }
  2999. @w{ @b{boole-xor} exclusive or }
  3000. @noindent
  3001. @w{ Figure 12--16: Bit-Wise Logical Operations }
  3002. @end group
  3003. }
  3004. @subsubheading Examples::
  3005. @example
  3006. (boole boole-ior 1 16) @result{} 17
  3007. (boole boole-and -2 5) @result{} 4
  3008. (boole boole-eqv 17 15) @result{} -31
  3009. ;;; These examples illustrate the result of applying BOOLE and each
  3010. ;;; of the possible values of OP to each possible combination of bits.
  3011. (progn
  3012. (format t "~&Results of (BOOLE <op> #b0011 #b0101) ...~
  3013. ~
  3014. (dolist (symbol '(boole-1 boole-2 boole-and boole-andc1
  3015. boole-andc2 boole-c1 boole-c2 boole-clr
  3016. boole-eqv boole-ior boole-nand boole-nor
  3017. boole-orc1 boole-orc2 boole-set boole-xor))
  3018. (let ((result (boole (symbol-value symbol) #b0011 #b0101)))
  3019. (format t "~& ~A~13T~3,' D~23T~:*~5,' B~31T ...~4,'0B~
  3020. symbol result (logand result #b1111)))))
  3021. @t{ |> } Results of (BOOLE <op> #b0011 #b0101) ...
  3022. @t{ |> } ---Op-------Decimal-----Binary----Bits---
  3023. @t{ |> } BOOLE-1 3 11 ...0011
  3024. @t{ |> } BOOLE-2 5 101 ...0101
  3025. @t{ |> } BOOLE-AND 1 1 ...0001
  3026. @t{ |> } BOOLE-ANDC1 4 100 ...0100
  3027. @t{ |> } BOOLE-ANDC2 2 10 ...0010
  3028. @t{ |> } BOOLE-C1 -4 -100 ...1100
  3029. @t{ |> } BOOLE-C2 -6 -110 ...1010
  3030. @t{ |> } BOOLE-CLR 0 0 ...0000
  3031. @t{ |> } BOOLE-EQV -7 -111 ...1001
  3032. @t{ |> } BOOLE-IOR 7 111 ...0111
  3033. @t{ |> } BOOLE-NAND -2 -10 ...1110
  3034. @t{ |> } BOOLE-NOR -8 -1000 ...1000
  3035. @t{ |> } BOOLE-ORC1 -3 -11 ...1101
  3036. @t{ |> } BOOLE-ORC2 -5 -101 ...1011
  3037. @t{ |> } BOOLE-SET -1 -1 ...1111
  3038. @t{ |> } BOOLE-XOR 6 110 ...0110
  3039. @result{} NIL
  3040. @end example
  3041. @subsubheading Exceptional Situations::
  3042. Should signal @b{type-error} if its first argument is not a
  3043. @i{bit-wise logical operation specifier} or if any subsequent argument is not
  3044. an @i{integer}.
  3045. @subsubheading See Also::
  3046. @ref{logand; logandc1; logandc2; logeqv; logior; lognand; lognor; lognot; logorc1; logorc2; logxor}
  3047. @subsubheading Notes::
  3048. In general,
  3049. @example
  3050. (boole boole-and x y) @equiv{} (logand x y)
  3051. @end example
  3052. @i{Programmers} who would prefer to use numeric indices rather than
  3053. @i{bit-wise logical operation specifiers} can get an equivalent effect
  3054. by a technique such as the following:
  3055. @example
  3056. ;; The order of the values in this `table' are such that
  3057. ;; (logand (boole (elt boole-n-vector n) #b0101 #b0011) #b1111) => n
  3058. (defconstant boole-n-vector
  3059. (vector boole-clr boole-and boole-andc1 boole-2
  3060. boole-andc2 boole-1 boole-xor boole-ior
  3061. boole-nor boole-eqv boole-c1 boole-orc1
  3062. boole-c2 boole-orc2 boole-nand boole-set))
  3063. @result{} BOOLE-N-VECTOR
  3064. (proclaim '(inline boole-n))
  3065. @result{} @i{implementation-dependent}
  3066. (defun boole-n (n integer &rest more-integers)
  3067. (apply #'boole (elt boole-n-vector n) integer more-integers))
  3068. @result{} BOOLE-N
  3069. (boole-n #b0111 5 3) @result{} 7
  3070. (boole-n #b0001 5 3) @result{} 1
  3071. (boole-n #b1101 5 3) @result{} -3
  3072. (loop for n from #b0000 to #b1111 collect (boole-n n 5 3))
  3073. @result{} (0 1 2 3 4 5 6 7 -8 -7 -6 -5 -4 -3 -2 -1)
  3074. @end example
  3075. @node boole-1, logand, boole, Numbers Dictionary
  3076. @subsection boole-1, boole-2, boole-and, boole-andc1, boole-andc2,
  3077. @subheading boole-c1, boole-c2, boole-clr, boole-eqv, boole-ior,
  3078. @subheading boole-nand, boole-nor, boole-orc1, boole-orc2, boole-set,
  3079. @subheading boole-xor
  3080. @flushright
  3081. @i{[Constant Variable]}
  3082. @end flushright
  3083. @subsubheading Constant Value::
  3084. The identity and nature of the @i{values} of each of these @i{variables}
  3085. is @i{implementation-dependent},
  3086. except that it must be @i{distinct} from each of the @i{values} of the others,
  3087. and it must be a valid first @i{argument} to the @i{function} @b{boole}.
  3088. @subsubheading Description::
  3089. Each of these @i{constants} has a @i{value} which is one of the
  3090. sixteen possible @i{bit-wise logical operation specifiers}.
  3091. @subsubheading Examples::
  3092. @example
  3093. (boole boole-ior 1 16) @result{} 17
  3094. (boole boole-and -2 5) @result{} 4
  3095. (boole boole-eqv 17 15) @result{} -31
  3096. @end example
  3097. @subsubheading See Also::
  3098. @ref{boole}
  3099. @node logand, logbitp, boole-1, Numbers Dictionary
  3100. @subsection logand, logandc1, logandc2, logeqv, logior,
  3101. @subheading lognand, lognor, lognot, logorc1, logorc2,
  3102. @subheading logxor
  3103. @flushright
  3104. @i{[Function]}
  3105. @end flushright
  3106. @code{logand} @i{{&rest} integers} @result{} @i{result-integer}
  3107. @code{logandc} @i{1} @result{} @i{integer-1 integer-2}
  3108. {result-integer}
  3109. @code{logandc} @i{2} @result{} @i{integer-1 integer-2}
  3110. {result-integer}
  3111. @code{logeqv} @i{{&rest} integers} @result{} @i{result-integer}
  3112. @code{logior} @i{{&rest} integers} @result{} @i{result-integer}
  3113. @code{lognand} @i{integer-1 integer-2} @result{} @i{result-integer}
  3114. @code{lognor} @i{integer-1 integer-2} @result{} @i{result-integer}
  3115. @code{lognot} @i{integer} @result{} @i{result-integer}
  3116. @code{logorc} @i{1} @result{} @i{integer-1 integer-2}
  3117. {result-integer}
  3118. @code{logorc} @i{2} @result{} @i{integer-1 integer-2}
  3119. {result-integer}
  3120. @code{logxor} @i{{&rest} integers} @result{} @i{result-integer}
  3121. @subsubheading Arguments and Values::
  3122. @i{integers}---@i{integers}.
  3123. @i{integer}---an @i{integer}.
  3124. @i{integer-1}---an @i{integer}.
  3125. @i{integer-2}---an @i{integer}.
  3126. @i{result-integer}---an @i{integer}.
  3127. @subsubheading Description::
  3128. The @i{functions}
  3129. @b{logandc1},
  3130. @b{logandc2},
  3131. @b{logand},
  3132. @b{logeqv},
  3133. @b{logior},
  3134. @b{lognand},
  3135. @b{lognor},
  3136. @b{lognot},
  3137. @b{logorc1},
  3138. @b{logorc2},
  3139. and @b{logxor}
  3140. perform bit-wise logical operations on their @i{arguments},
  3141. that are treated as if they were binary.
  3142. Figure 12--17 lists the meaning of each of the @i{functions}.
  3143. Where an `identity' is shown, it indicates the @i{value} @i{yielded}
  3144. by the @i{function} when no @i{arguments} are supplied.
  3145. @group
  3146. @noindent
  3147. @w{ Function Identity Operation performed }
  3148. @w{ @b{logandc1} --- and complement of @i{integer-1} with @i{integer-2} }
  3149. @w{ @b{logandc2} --- and @i{integer-1} with complement of @i{integer-2} }
  3150. @w{ @b{logand} @t{-1} and }
  3151. @w{ @b{logeqv} @t{-1} equivalence (exclusive nor) }
  3152. @w{ @b{logior} @t{0} inclusive or }
  3153. @w{ @b{lognand} --- complement of @i{integer-1} and @i{integer-2} }
  3154. @w{ @b{lognor} --- complement of @i{integer-1} or @i{integer-2} }
  3155. @w{ @b{lognot} --- complement }
  3156. @w{ @b{logorc1} --- or complement of @i{integer-1} with @i{integer-2} }
  3157. @w{ @b{logorc2} --- or @i{integer-1} with complement of @i{integer-2} }
  3158. @w{ @b{logxor} @t{0} exclusive or }
  3159. @noindent
  3160. @w{ Figure 12--17: Bit-wise Logical Operations on Integers }
  3161. @end group
  3162. Negative @i{integers} are treated as if they were in two's-complement notation.
  3163. @subsubheading Examples::
  3164. @example
  3165. (logior 1 2 4 8) @result{} 15
  3166. (logxor 1 3 7 15) @result{} 10
  3167. (logeqv) @result{} -1
  3168. (logand 16 31) @result{} 16
  3169. (lognot 0) @result{} -1
  3170. (lognot 1) @result{} -2
  3171. (lognot -1) @result{} 0
  3172. (lognot (1+ (lognot 1000))) @result{} 999
  3173. ;;; In the following example, m is a mask. For each bit in
  3174. ;;; the mask that is a 1, the corresponding bits in x and y are
  3175. ;;; exchanged. For each bit in the mask that is a 0, the
  3176. ;;; corresponding bits of x and y are left unchanged.
  3177. (flet ((show (m x y)
  3178. (format t "~
  3179. m x y)))
  3180. (let ((m #o007750)
  3181. (x #o452576)
  3182. (y #o317407))
  3183. (show m x y)
  3184. (let ((z (logand (logxor x y) m)))
  3185. (setq x (logxor z x))
  3186. (setq y (logxor z y))
  3187. (show m x y))))
  3188. @t{ |> } m = #o007750
  3189. @t{ |> } x = #o452576
  3190. @t{ |> } y = #o317407
  3191. @t{ |> }
  3192. @t{ |> } m = #o007750
  3193. @t{ |> } x = #o457426
  3194. @t{ |> } y = #o312557
  3195. @result{} NIL
  3196. @end example
  3197. @subsubheading Exceptional Situations::
  3198. Should signal @b{type-error} if any argument is not an @i{integer}.
  3199. @subsubheading See Also::
  3200. @ref{boole}
  3201. @subsubheading Notes::
  3202. @t{(logbitp @i{k} -1)} returns @i{true} for all values of @i{k}.
  3203. Because the following functions are not associative,
  3204. they take exactly two arguments rather than any number
  3205. of arguments.
  3206. @example
  3207. (lognand @i{n1} @i{n2}) @equiv{} (lognot (logand @i{n1} @i{n2}))
  3208. (lognor @i{n1} @i{n2}) @equiv{} (lognot (logior @i{n1} @i{n2}))
  3209. (logandc1 @i{n1} @i{n2}) @equiv{} (logand (lognot @i{n1}) @i{n2})
  3210. (logandc2 @i{n1} @i{n2}) @equiv{} (logand @i{n1} (lognot @i{n2}))
  3211. (logiorc1 @i{n1} @i{n2}) @equiv{} (logior (lognot @i{n1}) @i{n2})
  3212. (logiorc2 @i{n1} @i{n2}) @equiv{} (logior @i{n1} (lognot @i{n2}))
  3213. (logbitp @i{j} (lognot @i{x})) @equiv{} (not (logbitp @i{j} @i{x}))
  3214. @end example
  3215. @node logbitp, logcount, logand, Numbers Dictionary
  3216. @subsection logbitp [Function]
  3217. @code{logbitp} @i{index integer} @result{} @i{generalized-boolean}
  3218. @subsubheading Arguments and Values::
  3219. @i{index}---a non-negative @i{integer}.
  3220. @i{integer}---an @i{integer}.
  3221. @i{generalized-boolean}---a @i{generalized boolean}.
  3222. @subsubheading Description::
  3223. @b{logbitp} is used to test the value of a particular bit
  3224. in @i{integer}, that is treated as if it were binary.
  3225. The value of @b{logbitp} is @i{true} if the bit in @i{integer}
  3226. whose index is @i{index} (that is, its weight is 2^@i{index})
  3227. is a one-bit; otherwise it is @i{false}.
  3228. Negative @i{integers} are treated as if they were in
  3229. two's-complement notation.
  3230. @subsubheading Examples::
  3231. @example
  3232. (logbitp 1 1) @result{} @i{false}
  3233. (logbitp 0 1) @result{} @i{true}
  3234. (logbitp 3 10) @result{} @i{true}
  3235. (logbitp 1000000 -1) @result{} @i{true}
  3236. (logbitp 2 6) @result{} @i{true}
  3237. (logbitp 0 6) @result{} @i{false}
  3238. @end example
  3239. @subsubheading Exceptional Situations::
  3240. Should signal an error of @i{type} @b{type-error}
  3241. if @i{index} is not a non-negative @i{integer}.
  3242. Should signal an error of @i{type} @b{type-error}
  3243. if @i{integer} is not an @i{integer}.
  3244. @subsubheading Notes::
  3245. @example
  3246. (logbitp @i{k} @i{n}) @equiv{} (ldb-test (byte 1 @i{k}) @i{n})
  3247. @end example
  3248. @node logcount, logtest, logbitp, Numbers Dictionary
  3249. @subsection logcount [Function]
  3250. @code{logcount} @i{integer} @result{} @i{number-of-on-bits}
  3251. @subsubheading Arguments and Values::
  3252. @i{integer}---an @i{integer}.
  3253. @i{number-of-on-bits}---a non-negative @i{integer}.
  3254. @subsubheading Description::
  3255. Computes and returns the number of bits
  3256. in the two's-complement binary representation of @i{integer}
  3257. that are `on' or `set'.
  3258. If @i{integer} is negative, the @t{0} bits are counted;
  3259. otherwise, the @t{1} bits are counted.
  3260. @subsubheading Examples::
  3261. @example
  3262. (logcount 0) @result{} 0
  3263. (logcount -1) @result{} 0
  3264. (logcount 7) @result{} 3
  3265. (logcount 13) @result{} 3 ;Two's-complement binary: ...0001101
  3266. (logcount -13) @result{} 2 ;Two's-complement binary: ...1110011
  3267. (logcount 30) @result{} 4 ;Two's-complement binary: ...0011110
  3268. (logcount -30) @result{} 4 ;Two's-complement binary: ...1100010
  3269. (logcount (expt 2 100)) @result{} 1
  3270. (logcount (- (expt 2 100))) @result{} 100
  3271. (logcount (- (1+ (expt 2 100)))) @result{} 1
  3272. @end example
  3273. @subsubheading Exceptional Situations::
  3274. Should signal @b{type-error} if its argument is not an @i{integer}.
  3275. @subsubheading Notes::
  3276. Even if the @i{implementation} does not represent @i{integers} internally
  3277. in two's complement binary, @b{logcount} behaves as if it did.
  3278. The following identity always holds:
  3279. @example
  3280. (logcount @i{x})
  3281. @equiv{} (logcount (- (+ @i{x} 1)))
  3282. @equiv{} (logcount (lognot @i{x}))
  3283. @end example
  3284. @node logtest, byte, logcount, Numbers Dictionary
  3285. @subsection logtest [Function]
  3286. @code{logtest} @i{integer-1 integer-2} @result{} @i{generalized-boolean}
  3287. @subsubheading Arguments and Values::
  3288. @i{integer-1}---an @i{integer}.
  3289. @i{integer-2}---an @i{integer}.
  3290. @i{generalized-boolean}---a @i{generalized boolean}.
  3291. @subsubheading Description::
  3292. Returns @i{true} if any of the bits designated by the 1's
  3293. in @i{integer-1} is 1 in @i{integer-2};
  3294. otherwise it is @i{false}.
  3295. @i{integer-1} and @i{integer-2} are treated as if they were binary.
  3296. Negative @i{integer-1} and @i{integer-2} are treated as if
  3297. they were represented in two's-complement binary.
  3298. @subsubheading Examples::
  3299. @example
  3300. (logtest 1 7) @result{} @i{true}
  3301. (logtest 1 2) @result{} @i{false}
  3302. (logtest -2 -1) @result{} @i{true}
  3303. (logtest 0 -1) @result{} @i{false}
  3304. @end example
  3305. @subsubheading Exceptional Situations::
  3306. Should signal an error of @i{type} @b{type-error}
  3307. if @i{integer-1} is not an @i{integer}.
  3308. Should signal an error of @i{type} @b{type-error}
  3309. if @i{integer-2} is not an @i{integer}.
  3310. @subsubheading Notes::
  3311. @example
  3312. (logtest @i{x} @i{y}) @equiv{} (not (zerop (logand @i{x} @i{y})))
  3313. @end example
  3314. @node byte, deposit-field, logtest, Numbers Dictionary
  3315. @subsection byte, byte-size, byte-position [Function]
  3316. @code{byte} @i{size position} @result{} @i{bytespec}
  3317. @code{byte-size} @i{bytespec} @result{} @i{size}
  3318. @code{byte-position} @i{bytespec} @result{} @i{position}
  3319. @subsubheading Arguments and Values::
  3320. @i{size}, @i{position}---a non-negative @i{integer}.
  3321. @i{bytespec}---a @i{byte specifier}.
  3322. @subsubheading Description::
  3323. @b{byte} returns a @i{byte specifier} that indicates
  3324. a @i{byte} of width @i{size} and whose bits have weights
  3325. 2^{@i{position} + @i{size} - 1\/} through 2^@i{position},
  3326. and whose representation is
  3327. @i{implementation-dependent}.
  3328. @b{byte-size} returns the number of bits specified by @i{bytespec}.
  3329. @b{byte-position} returns the position specified by @i{bytespec}.
  3330. @subsubheading Examples::
  3331. @example
  3332. (setq b (byte 100 200)) @result{} #<BYTE-SPECIFIER size 100 position 200>
  3333. (byte-size b) @result{} 100
  3334. (byte-position b) @result{} 200
  3335. @end example
  3336. @subsubheading See Also::
  3337. @ref{ldb}
  3338. ,
  3339. @ref{dpb}
  3340. @subsubheading Notes::
  3341. @example
  3342. (byte-size (byte @i{j} @i{k})) @equiv{} @i{j}
  3343. (byte-position (byte @i{j} @i{k})) @equiv{} @i{k}
  3344. @end example
  3345. A @i{byte} of @i{size} of @t{0} is permissible;
  3346. it refers to a @i{byte} of width zero. For example,
  3347. @example
  3348. (ldb (byte 0 3) #o7777) @result{} 0
  3349. (dpb #o7777 (byte 0 3) 0) @result{} 0
  3350. @end example
  3351. @node deposit-field, dpb, byte, Numbers Dictionary
  3352. @subsection deposit-field [Function]
  3353. @code{deposit-field} @i{newbyte bytespec integer} @result{} @i{result-integer}
  3354. @subsubheading Arguments and Values::
  3355. @i{newbyte}---an @i{integer}.
  3356. @i{bytespec}---a @i{byte specifier}.
  3357. @i{integer}---an @i{integer}.
  3358. @i{result-integer}---an @i{integer}.
  3359. @subsubheading Description::
  3360. Replaces a field of bits within @i{integer}; specifically,
  3361. returns an @i{integer} that contains the bits of @i{newbyte}
  3362. within the @i{byte} specified by @i{bytespec},
  3363. and elsewhere contains the bits of @i{integer}.
  3364. @subsubheading Examples::
  3365. @example
  3366. (deposit-field 7 (byte 2 1) 0) @result{} 6
  3367. (deposit-field -1 (byte 4 0) 0) @result{} 15
  3368. (deposit-field 0 (byte 2 1) -3) @result{} -7
  3369. @end example
  3370. @subsubheading See Also::
  3371. @ref{byte; byte-size; byte-position}
  3372. ,
  3373. @ref{dpb}
  3374. @subsubheading Notes::
  3375. @example
  3376. (logbitp @i{j} (deposit-field @i{m} (byte @i{s} @i{p}) @i{n}))
  3377. @equiv{} (if (and (>= @i{j} @i{p}) (< @i{j} (+ @i{p} @i{s})))
  3378. (logbitp @i{j} @i{m})
  3379. (logbitp @i{j} @i{n}))
  3380. @end example
  3381. @b{deposit-field} is to @b{mask-field}
  3382. as @b{dpb} is to @b{ldb}.
  3383. @node dpb, ldb, deposit-field, Numbers Dictionary
  3384. @subsection dpb [Function]
  3385. @code{dpb} @i{newbyte bytespec integer} @result{} @i{result-integer}
  3386. @subsubheading Pronunciation::
  3387. pronounced ,de 'pib
  3388. or pronounced ,de 'pe b
  3389. or pronounced 'd\=e 'p\=e 'b\=e
  3390. @subsubheading Arguments and Values::
  3391. @i{newbyte}---an @i{integer}.
  3392. @i{bytespec}---a @i{byte specifier}.
  3393. @i{integer}---an @i{integer}.
  3394. @i{result-integer}---an @i{integer}.
  3395. @subsubheading Description::
  3396. @b{dpb} (deposit byte) is used to
  3397. replace a field of bits within @i{integer}.
  3398. @b{dpb} returns an @i{integer} that is
  3399. the same as @i{integer} except in the bits specified by @i{bytespec}.
  3400. Let @t{s} be the size specified
  3401. by @i{bytespec}; then the low @t{s} bits of @i{newbyte} appear in
  3402. the result in the byte specified by @i{bytespec}.
  3403. @i{Newbyte} is interpreted as
  3404. being right-justified, as if it were the result of @b{ldb}.
  3405. @subsubheading Examples::
  3406. @example
  3407. (dpb 1 (byte 1 10) 0) @result{} 1024
  3408. (dpb -2 (byte 2 10) 0) @result{} 2048
  3409. (dpb 1 (byte 2 10) 2048) @result{} 1024
  3410. @end example
  3411. @subsubheading See Also::
  3412. @ref{byte; byte-size; byte-position}
  3413. ,
  3414. @ref{deposit-field}
  3415. ,
  3416. @ref{ldb}
  3417. @subsubheading Notes::
  3418. @example
  3419. (logbitp @i{j} (dpb @i{m} (byte @i{s} @i{p}) @i{n}))
  3420. @equiv{} (if (and (>= @i{j} @i{p}) (< @i{j} (+ @i{p} @i{s})))
  3421. (logbitp (- @i{j} @i{p}) @i{m})
  3422. (logbitp @i{j} @i{n}))
  3423. @end example
  3424. In general,
  3425. @example
  3426. (dpb @i{x} (byte 0 @i{y}) @i{z}) @result{} @i{z}
  3427. @end example
  3428. for all valid values of @i{x}, @i{y}, and @i{z}.
  3429. Historically, the name ``dpb'' comes from a DEC PDP-10 assembly language
  3430. instruction meaning ``deposit byte.''
  3431. @node ldb, ldb-test, dpb, Numbers Dictionary
  3432. @subsection ldb [Accessor]
  3433. @code{ldb} @i{bytespec integer} @result{} @i{byte}
  3434. (setf (@code{ ldb} @i{bytespec place}) new-byte)@*
  3435. @subsubheading Pronunciation::
  3436. pronounced 'lid ib
  3437. or pronounced 'lid e b
  3438. or pronounced 'el 'd\=e 'b\=e
  3439. @subsubheading Arguments and Values::
  3440. @i{bytespec}---a @i{byte specifier}.
  3441. @i{integer}---an @i{integer}.
  3442. @i{byte}, @i{new-byte}---a non-negative @i{integer}.
  3443. @subsubheading Description::
  3444. @b{ldb} extracts and returns the @i{byte} of @i{integer}
  3445. specified by @i{bytespec}.
  3446. @b{ldb} returns an @i{integer} in which the bits with weights
  3447. 2^{(@i{s}-1)} through 2^{0} are the same as those in
  3448. @i{integer} with weights 2^{(@i{p}+@i{s}-1)}
  3449. through 2^@i{p}, and all other bits zero; @i{s} is
  3450. @t{(byte-size @i{bytespec})}
  3451. and @i{p} is @t{(byte-position @i{bytespec})}.
  3452. @b{setf} may be used with @b{ldb} to modify
  3453. a byte within the @i{integer} that is stored
  3454. in a given @i{place}.
  3455. The order of evaluation, when an @b{ldb} form is supplied
  3456. to @b{setf}, is exactly left-to-right.
  3457. @ITindex{order of evaluation}
  3458. @ITindex{evaluation order}
  3459. The effect is to perform a @b{dpb} operation
  3460. and then store the result back into the @i{place}.
  3461. @subsubheading Examples::
  3462. @example
  3463. (ldb (byte 2 1) 10) @result{} 1
  3464. (setq a (list 8)) @result{} (8)
  3465. (setf (ldb (byte 2 1) (car a)) 1) @result{} 1
  3466. a @result{} (10)
  3467. @end example
  3468. @subsubheading See Also::
  3469. @ref{byte; byte-size; byte-position}
  3470. ,
  3471. @b{byte-position},
  3472. @b{byte-size},
  3473. @ref{dpb}
  3474. @subsubheading Notes::
  3475. @example
  3476. (logbitp @i{j} (ldb (byte @i{s} @i{p}) @i{n}))
  3477. @equiv{} (and (< @i{j} @i{s}) (logbitp (+ @i{j} @i{p}) @i{n}))
  3478. @end example
  3479. In general,
  3480. @example
  3481. (ldb (byte 0 @i{x}) @i{y}) @result{} 0
  3482. @end example
  3483. for all valid values of @i{x} and @i{y}.
  3484. Historically, the name ``ldb'' comes from a DEC PDP-10 assembly language
  3485. instruction meaning ``load byte.''
  3486. @node ldb-test, mask-field, ldb, Numbers Dictionary
  3487. @subsection ldb-test [Function]
  3488. @code{ldb-test} @i{bytespec integer} @result{} @i{generalized-boolean}
  3489. @subsubheading Arguments and Values::
  3490. @i{bytespec}---a @i{byte specifier}.
  3491. @i{integer}---an @i{integer}.
  3492. @i{generalized-boolean}---a @i{generalized boolean}.
  3493. @subsubheading Description::
  3494. Returns @i{true} if any of the bits of the byte in @i{integer}
  3495. specified by @i{bytespec} is non-zero; otherwise returns @i{false}.
  3496. @subsubheading Examples::
  3497. @example
  3498. (ldb-test (byte 4 1) 16) @result{} @i{true}
  3499. (ldb-test (byte 3 1) 16) @result{} @i{false}
  3500. (ldb-test (byte 3 2) 16) @result{} @i{true}
  3501. @end example
  3502. @subsubheading See Also::
  3503. @ref{byte; byte-size; byte-position}
  3504. ,
  3505. @ref{ldb}
  3506. ,
  3507. @ref{zerop}
  3508. @subsubheading Notes::
  3509. @example
  3510. (ldb-test bytespec n) @equiv{}
  3511. (not (zerop (ldb bytespec n))) @equiv{}
  3512. (logtest (ldb bytespec -1) n)
  3513. @end example
  3514. @node mask-field, most-positive-fixnum, ldb-test, Numbers Dictionary
  3515. @subsection mask-field [Accessor]
  3516. @code{mask-field} @i{bytespec integer} @result{} @i{masked-integer}
  3517. (setf (@code{ mask-field} @i{bytespec place}) new-masked-integer)@*
  3518. @subsubheading Arguments and Values::
  3519. @i{bytespec}---a @i{byte specifier}.
  3520. @i{integer}---an @i{integer}.
  3521. @i{masked-integer}, @i{new-masked-integer}---a non-negative @i{integer}.
  3522. @subsubheading Description::
  3523. @b{mask-field} performs a ``mask'' operation on @i{integer}.
  3524. It returns an @i{integer} that has the same bits as @i{integer} in
  3525. the @i{byte} specified by @i{bytespec}, but that has zero-bits everywhere else.
  3526. @b{setf} may be used with @b{mask-field}
  3527. to modify a byte within the @i{integer} that is stored
  3528. in a given @i{place}.
  3529. The effect is to perform a @b{deposit-field} operation
  3530. and then store the result back into the @i{place}.
  3531. @subsubheading Examples::
  3532. @example
  3533. (mask-field (byte 1 5) -1) @result{} 32
  3534. (setq a 15) @result{} 15
  3535. (mask-field (byte 2 0) a) @result{} 3
  3536. a @result{} 15
  3537. (setf (mask-field (byte 2 0) a) 1) @result{} 1
  3538. a @result{} 13
  3539. @end example
  3540. @subsubheading See Also::
  3541. @ref{byte; byte-size; byte-position}
  3542. ,
  3543. @ref{ldb}
  3544. @subsubheading Notes::
  3545. @example
  3546. (ldb @i{bs} (mask-field @i{bs} @i{n})) @equiv{} (ldb @i{bs} @i{n})
  3547. (logbitp @i{j} (mask-field (byte @i{s} @i{p}) @i{n}))
  3548. @equiv{} (and (>= @i{j} @i{p}) (< @i{j} @i{s}) (logbitp @i{j} @i{n}))
  3549. (mask-field @i{bs} @i{n}) @equiv{} (logand @i{n} (dpb -1 @i{bs} 0))
  3550. @end example
  3551. @node most-positive-fixnum, decode-float, mask-field, Numbers Dictionary
  3552. @subsection most-positive-fixnum, most-negative-fixnum [Constant Variable]
  3553. @subsubheading Constant Value::
  3554. @i{implementation-dependent}.
  3555. @subsubheading Description::
  3556. @b{most-positive-fixnum} is that @i{fixnum} closest in value
  3557. to positive infinity provided by the implementation,
  3558. and greater than or equal to both 2^{15} - 1 and
  3559. @b{array-dimension-limit}.
  3560. @b{most-negative-fixnum} is that @i{fixnum} closest in value
  3561. to negative infinity provided by the implementation,
  3562. and less than or equal to -2^{15}.
  3563. @node decode-float, float, most-positive-fixnum, Numbers Dictionary
  3564. @subsection decode-float, scale-float, float-radix, float-sign,
  3565. @subheading float-digits, float-precision, integer-decode-float
  3566. @flushright
  3567. @i{[Function]}
  3568. @end flushright
  3569. @code{decode-float} @i{float} @result{} @i{significand, exponent, sign}
  3570. @code{scale-float} @i{float integer} @result{} @i{scaled-float}
  3571. @code{float-radix} @i{float} @result{} @i{float-radix}
  3572. @code{float-sign} @i{float-1 {&optional} float-2} @result{} @i{signed-float}
  3573. @code{float-digits} @i{float} @result{} @i{digits1}
  3574. @code{float-precision} @i{float} @result{} @i{digits2}
  3575. @code{integer-decode-float} @i{float} @result{} @i{significand, exponent, integer-sign}
  3576. @subsubheading Arguments and Values::
  3577. @i{digits1}---a non-negative @i{integer}.
  3578. @i{digits2}---a non-negative @i{integer}.
  3579. @i{exponent}---an @i{integer}.
  3580. @i{float}---a @i{float}.
  3581. @i{float-1}---a @i{float}.
  3582. @i{float-2}---a @i{float}.
  3583. @i{float-radix}---an @i{integer}.
  3584. @i{integer}---a non-negative @i{integer}.
  3585. @i{integer-sign}---the @i{integer} @t{-1},
  3586. or the @i{integer} @t{1}.
  3587. @i{scaled-float}---a @i{float}.
  3588. @i{sign}---A @i{float} of the same @i{type} as @i{float}
  3589. but numerically equal to @t{1.0} or @t{-1.0}.
  3590. @i{signed-float}---a @i{float}.
  3591. @i{significand}---a @i{float}.
  3592. @subsubheading Description::
  3593. @b{decode-float} computes three values that characterize
  3594. @i{float}.
  3595. The first value is of the same @i{type}
  3596. as @i{float} and
  3597. represents the significand.
  3598. The second value represents the exponent
  3599. to which the radix (notated in this description by @i{b}) must
  3600. be raised to obtain the value that, when multiplied with the first
  3601. result, produces the absolute value of @i{float}.
  3602. If @i{float} is zero, any @i{integer} value may be returned,
  3603. provided that the identity shown for @b{scale-float} holds.
  3604. The third value
  3605. is of the same @i{type} as @i{float}
  3606. and is 1.0 if @i{float} is greater
  3607. than or equal to zero or -1.0 otherwise.
  3608. @b{decode-float}
  3609. divides @i{float} by an integral power of @i{b}
  3610. so as to bring its value between 1/@i{b} (inclusive) and~1 (exclusive),
  3611. and returns the quotient as the first value.
  3612. If @i{float} is zero, however, the result
  3613. equals the absolute value of @i{float} (that is, if there is a negative
  3614. zero, its significand is considered to be a positive zero).
  3615. @b{scale-float} returns
  3616. @t{(* @i{float} (expt (float @i{b} @i{float})
  3617. @i{integer}))\/}, where @i{b} is the radix of the floating-point
  3618. representation. @i{float} is not necessarily between 1/@i{b} and~1.
  3619. @b{float-radix} returns
  3620. the radix of @i{float}.
  3621. @b{float-sign} returns a number @t{z} such
  3622. that @t{z} and @i{float-1} have the same sign and also such that
  3623. @t{z} and @i{float-2} have the same absolute value.
  3624. If @i{float-2} is not supplied, its value is @t{(float 1 @i{float-1})}.
  3625. If an implementation
  3626. has distinct representations for negative zero and positive zero,
  3627. then @t{(float-sign -0.0)} @result{} @t{-1.0}.
  3628. @b{float-digits} returns
  3629. the number of radix @i{b} digits
  3630. used in the representation of @i{float} (including any implicit
  3631. digits, such as a ``hidden bit'').
  3632. @b{float-precision}
  3633. returns
  3634. the number of significant radix @i{b} digits present in @i{float};
  3635. if @i{float} is a @i{float}
  3636. zero, then the result is an @i{integer} zero.
  3637. For @i{normalized} @i{floats},
  3638. the results of @b{float-digits} and @b{float-precision} are the same,
  3639. but the precision is less than the number of representation digits
  3640. for a @i{denormalized} or zero number.
  3641. @b{integer-decode-float} computes three values that characterize
  3642. @i{float} -
  3643. the significand scaled so as to be an @i{integer},
  3644. and the same last two
  3645. values that are returned by @b{decode-float}.
  3646. If @i{float} is zero, @b{integer-decode-float} returns
  3647. zero as the first value.
  3648. The second value bears the same relationship to the first value
  3649. as for @b{decode-float}:
  3650. @example
  3651. (multiple-value-bind (signif expon sign)
  3652. (integer-decode-float f)
  3653. (scale-float (float signif f) expon)) @equiv{} (abs f)
  3654. @end example
  3655. @subsubheading Examples::
  3656. @example
  3657. ;; Note that since the purpose of this functionality is to expose
  3658. ;; details of the implementation, all of these examples are necessarily
  3659. ;; very implementation-dependent. Results may vary widely.
  3660. ;; Values shown here are chosen consistently from one particular implementation.
  3661. (decode-float .5) @result{} 0.5, 0, 1.0
  3662. (decode-float 1.0) @result{} 0.5, 1, 1.0
  3663. (scale-float 1.0 1) @result{} 2.0
  3664. (scale-float 10.01 -2) @result{} 2.5025
  3665. (scale-float 23.0 0) @result{} 23.0
  3666. (float-radix 1.0) @result{} 2
  3667. (float-sign 5.0) @result{} 1.0
  3668. (float-sign -5.0) @result{} -1.0
  3669. (float-sign 0.0) @result{} 1.0
  3670. (float-sign 1.0 0.0) @result{} 0.0
  3671. (float-sign 1.0 -10.0) @result{} 10.0
  3672. (float-sign -1.0 10.0) @result{} -10.0
  3673. (float-digits 1.0) @result{} 24
  3674. (float-precision 1.0) @result{} 24
  3675. (float-precision least-positive-single-float) @result{} 1
  3676. (integer-decode-float 1.0) @result{} 8388608, -23, 1
  3677. @end example
  3678. @subsubheading Affected By::
  3679. The implementation's representation for @i{floats}.
  3680. @subsubheading Exceptional Situations::
  3681. The functions @b{decode-float}, @b{float-radix}, @b{float-digits},
  3682. @b{float-precision}, and @b{integer-decode-float} should signal an error
  3683. if their only argument is not a @i{float}.
  3684. The @i{function} @b{scale-float} should signal an error if its first argument
  3685. is not a @i{float} or if its second argument is not an @i{integer}.
  3686. The @i{function} @b{float-sign} should signal an error if its first argument
  3687. is not a @i{float} or if its second argument is supplied but is
  3688. not a @i{float}.
  3689. @subsubheading Notes::
  3690. The product of the first result of @b{decode-float} or @b{integer-decode-float},
  3691. of the radix raised to the power of the second result, and of the third result
  3692. is exactly equal to the value of @i{float}.
  3693. @example
  3694. (multiple-value-bind (signif expon sign)
  3695. (decode-float f)
  3696. (scale-float signif expon))
  3697. @equiv{} (abs f)
  3698. @end example
  3699. and
  3700. @example
  3701. (multiple-value-bind (signif expon sign)
  3702. (decode-float f)
  3703. (* (scale-float signif expon) sign))
  3704. @equiv{} f
  3705. @end example
  3706. @node float, floatp, decode-float, Numbers Dictionary
  3707. @subsection float [Function]
  3708. @code{float} @i{number {&optional} prototype} @result{} @i{float}
  3709. @subsubheading Arguments and Values::
  3710. @i{number}---a @i{real}.
  3711. @i{prototype}---a @i{float}.
  3712. @i{float}---a @i{float}.
  3713. @subsubheading Description::
  3714. @b{float} converts a
  3715. @i{real}
  3716. number to a @i{float}.
  3717. If a @i{prototype} is supplied,
  3718. a @i{float} is returned that is mathematically equal to @i{number}
  3719. but has the same format as @i{prototype}.
  3720. If @i{prototype} is not supplied,
  3721. then if the @i{number} is already a @i{float}, it is returned;
  3722. otherwise, a @i{float} is returned that is mathematically equal to @i{number}
  3723. but is a @i{single float}.
  3724. @subsubheading Examples::
  3725. @example
  3726. (float 0) @result{} 0.0
  3727. (float 1 .5) @result{} 1.0
  3728. (float 1.0) @result{} 1.0
  3729. (float 1/2) @result{} 0.5
  3730. @result{} 1.0d0
  3731. @i{OR}@result{} 1.0
  3732. (eql (float 1.0 1.0d0) 1.0d0) @result{} @i{true}
  3733. @end example
  3734. @subsubheading See Also::
  3735. @ref{coerce}
  3736. @node floatp, most-positive-short-float, float, Numbers Dictionary
  3737. @subsection floatp [Function]
  3738. @code{floatp} @i{object}
  3739. {generalized-boolean}
  3740. @subsubheading Arguments and Values::
  3741. @i{object}---an @i{object}.
  3742. @i{generalized-boolean}---a @i{generalized boolean}.
  3743. @subsubheading Description::
  3744. Returns @i{true} if @i{object} is of @i{type} @b{float};
  3745. otherwise, returns @i{false}.
  3746. @subsubheading Examples::
  3747. @example
  3748. (floatp 1.2d2) @result{} @i{true}
  3749. (floatp 1.212) @result{} @i{true}
  3750. (floatp 1.2s2) @result{} @i{true}
  3751. (floatp (expt 2 130)) @result{} @i{false}
  3752. @end example
  3753. @subsubheading Notes::
  3754. @example
  3755. (floatp @i{object}) @equiv{} (typep @i{object} 'float)
  3756. @end example
  3757. @node most-positive-short-float, short-float-epsilon, floatp, Numbers Dictionary
  3758. @subsection most-positive-short-float, least-positive-short-float,
  3759. @subheading least-positive-normalized-short-float,
  3760. @subheading most-positive-double-float, least-positive-double-float,
  3761. @subheading least-positive-normalized-double-float,
  3762. @subheading most-positive-long-float, least-positive-long-float,
  3763. @subheading least-positive-normalized-long-float,
  3764. @subheading most-positive-single-float, least-positive-single-float,
  3765. @subheading least-positive-normalized-single-float,
  3766. @subheading most-negative-short-float, least-negative-short-float,
  3767. @subheading least-negative-normalized-short-float,
  3768. @subheading most-negative-single-float, least-negative-single-float,
  3769. @subheading least-negative-normalized-single-float,
  3770. @subheading most-negative-double-float, least-negative-double-float,
  3771. @subheading least-negative-normalized-double-float,
  3772. @subheading most-negative-long-float, least-negative-long-float,
  3773. @subheading least-negative-normalized-long-float
  3774. @flushright
  3775. @i{[Constant Variable]}
  3776. @end flushright
  3777. @subsubheading Constant Value::
  3778. @i{implementation-dependent}.
  3779. @subsubheading Description::
  3780. These @i{constant variables} provide a way for programs to examine
  3781. the @i{implementation-defined} limits for the various float formats.
  3782. Of these @i{variables},
  3783. each which has ``@t{-normalized}'' in its @i{name}
  3784. must have a @i{value} which is a @i{normalized} @i{float}, and
  3785. each which does not have ``@t{-normalized}'' in its name
  3786. may have a @i{value} which is either a @i{normalized} @i{float}
  3787. or a @i{denormalized} @i{float}, as appropriate.
  3788. Of these @i{variables},
  3789. each which has ``@t{short-float}'' in its name
  3790. must have a @i{value} which is a @i{short float},
  3791. each which has ``@t{single-float}'' in its name
  3792. must have a @i{value} which is a @i{single float},
  3793. each which has ``@t{double-float}'' in its name
  3794. must have a @i{value} which is a @i{double float}, and
  3795. each which has ``@t{long-float}'' in its name
  3796. must have a @i{value} which is a @i{long float}.
  3797. @table @asis
  3798. @item @t{*}
  3799. @b{most-positive-short-float},
  3800. @b{most-positive-single-float},
  3801. @b{most-positive-double-float},
  3802. @b{most-positive-long-float}
  3803. Each of these @i{constant variables} has as its @i{value}
  3804. the positive @i{float} of the largest magnitude
  3805. (closest in value to, but not equal to, positive infinity)
  3806. for the float format implied by its name.
  3807. @item @t{*}
  3808. @b{least-positive-short-float},
  3809. @b{least-positive-normalized-short-float},
  3810. @b{least-positive-single-float},
  3811. @b{least-positive-normalized-single-float},
  3812. @b{least-positive-double-float},
  3813. @b{least-positive-normalized-double-float},
  3814. @b{least-positive-long-float},
  3815. @b{least-positive-normalized-long-float}
  3816. Each of these @i{constant variables} has as its @i{value}
  3817. the smallest positive (nonzero) @i{float}
  3818. for the float format implied by its name.
  3819. @item @t{*}
  3820. @b{least-negative-short-float},
  3821. @b{least-negative-normalized-short-float},
  3822. @b{least-negative-single-float},
  3823. @b{least-negative-normalized-single-float},
  3824. @b{least-negative-double-float},
  3825. @b{least-negative-normalized-double-float},
  3826. @b{least-negative-long-float},
  3827. @b{least-negative-normalized-long-float}
  3828. Each of these @i{constant variables} has as its @i{value}
  3829. the negative (nonzero) @i{float} of the smallest magnitude
  3830. for the float format implied by its name.
  3831. (If an implementation supports minus zero as a @i{different}
  3832. @i{object} from positive zero, this value must not be minus zero.)
  3833. @item @t{*}
  3834. @b{most-negative-short-float},
  3835. @b{most-negative-single-float},
  3836. @b{most-negative-double-float},
  3837. @b{most-negative-long-float}
  3838. Each of these @i{constant variables} has as its @i{value}
  3839. the negative @i{float} of the largest magnitude
  3840. (closest in value to, but not equal to, negative infinity)
  3841. for the float format implied by its name.
  3842. @end table
  3843. @subsubheading Notes::
  3844. @node short-float-epsilon, arithmetic-error, most-positive-short-float, Numbers Dictionary
  3845. @subsection short-float-epsilon, short-float-negative-epsilon,
  3846. @subheading single-float-epsilon, single-float-negative-epsilon,
  3847. @subheading double-float-epsilon, double-float-negative-epsilon,
  3848. @subheading long-float-epsilon, long-float-negative-epsilon
  3849. @flushright
  3850. @i{[Constant Variable]}
  3851. @end flushright
  3852. @subsubheading Constant Value::
  3853. @i{implementation-dependent}.
  3854. @subsubheading Description::
  3855. The value of each of the constants @b{short-float-epsilon},
  3856. @b{single-float-epsilon},
  3857. @b{double-float-epsilon}, and @b{long-float-epsilon} is
  3858. the smallest positive @i{float} \epsilon of the given format,
  3859. such that the following expression is @i{true} when evaluated:
  3860. @t{(not (= (float 1 \epsilon) (+ (float 1 \epsilon) \epsilon)))\/}
  3861. The value of each of the constants @b{short-float-negative-epsilon},
  3862. @b{single-float-negative-epsilon},
  3863. @b{double-float-negative-epsilon}, and
  3864. @b{long-float-negative-epsilon} is the smallest positive
  3865. @i{float} \epsilon of the given format, such that the following
  3866. expression is @i{true} when evaluated:
  3867. @t{(not (= (float 1 \epsilon) (- (float 1 \epsilon) \epsilon)))\/}
  3868. @node arithmetic-error, arithmetic-error-operands, short-float-epsilon, Numbers Dictionary
  3869. @subsection arithmetic-error [Condition Type]
  3870. @subsubheading Class Precedence List::
  3871. @b{arithmetic-error},
  3872. @b{error},
  3873. @b{serious-condition},
  3874. @b{condition},
  3875. @b{t}
  3876. @subsubheading Description::
  3877. The @i{type} @b{arithmetic-error} consists of error conditions
  3878. that occur during arithmetic operations.
  3879. The operation and operands are initialized with
  3880. the initialization arguments named @t{:operation} and @t{:operands} to @b{make-condition},
  3881. and are @i{accessed} by
  3882. the functions @b{arithmetic-error-operation} and
  3883. @b{arithmetic-error-operands}.
  3884. @subsubheading See Also::
  3885. @b{arithmetic-error-operation},
  3886. @ref{arithmetic-error-operands; arithmetic-error-operation}
  3887. @node arithmetic-error-operands, division-by-zero, arithmetic-error, Numbers Dictionary
  3888. @subsection arithmetic-error-operands, arithmetic-error-operation [Function]
  3889. @code{arithmetic-error-operands} @i{condition} @result{} @i{operands}
  3890. @code{arithmetic-error-operation} @i{condition} @result{} @i{operation}
  3891. @subsubheading Arguments and Values::
  3892. @i{condition}---a @i{condition} of @i{type} @b{arithmetic-error}.
  3893. @i{operands}---a @i{list}.
  3894. @i{operation}---a @i{function designator}.
  3895. @subsubheading Description::
  3896. @b{arithmetic-error-operands} returns a @i{list} of the operands
  3897. which were used in the offending call to the operation that signaled
  3898. the @i{condition}.
  3899. @b{arithmetic-error-operation} returns a @i{list} of
  3900. the offending operation in the offending call that signaled the @i{condition}.
  3901. @subsubheading See Also::
  3902. @b{arithmetic-error},
  3903. {@ref{Conditions}}
  3904. @subsubheading Notes::
  3905. @node division-by-zero, floating-point-invalid-operation, arithmetic-error-operands, Numbers Dictionary
  3906. @subsection division-by-zero [Condition Type]
  3907. @subsubheading Class Precedence List::
  3908. @b{division-by-zero},
  3909. @b{arithmetic-error},
  3910. @b{error},
  3911. @b{serious-condition},
  3912. @b{condition},
  3913. @b{t}
  3914. @subsubheading Description::
  3915. The @i{type} @b{division-by-zero} consists of error conditions that
  3916. occur because of division by zero.
  3917. @node floating-point-invalid-operation, floating-point-inexact, division-by-zero, Numbers Dictionary
  3918. @subsection floating-point-invalid-operation [Condition Type]
  3919. @subsubheading Class Precedence List::
  3920. @b{floating-point-invalid-operation},
  3921. @b{arithmetic-error},
  3922. @b{error},
  3923. @b{serious-condition},
  3924. @b{condition},
  3925. @b{t}
  3926. @subsubheading Description::
  3927. The @i{type} @b{floating-point-invalid-operation} consists of
  3928. error conditions that occur because of certain
  3929. floating point traps.
  3930. It is @i{implementation-dependent} whether floating point traps
  3931. occur, and whether or how they may be enabled or disabled. Therefore,
  3932. conforming code may establish handlers for this condition, but must not
  3933. depend on its being @i{signaled}.
  3934. @node floating-point-inexact, floating-point-overflow, floating-point-invalid-operation, Numbers Dictionary
  3935. @subsection floating-point-inexact [Condition Type]
  3936. @subsubheading Class Precedence List::
  3937. @b{floating-point-inexact},
  3938. @b{arithmetic-error},
  3939. @b{error},
  3940. @b{serious-condition},
  3941. @b{condition},
  3942. @b{t}
  3943. @subsubheading Description::
  3944. The @i{type} @b{floating-point-inexact} consists of
  3945. error conditions that occur because of certain
  3946. floating point traps.
  3947. It is @i{implementation-dependent} whether floating point traps
  3948. occur, and whether or how they may be enabled or disabled. Therefore,
  3949. conforming code may establish handlers for this condition, but must not
  3950. depend on its being @i{signaled}.
  3951. @node floating-point-overflow, floating-point-underflow, floating-point-inexact, Numbers Dictionary
  3952. @subsection floating-point-overflow [Condition Type]
  3953. @subsubheading Class Precedence List::
  3954. @b{floating-point-overflow},
  3955. @b{arithmetic-error},
  3956. @b{error},
  3957. @b{serious-condition},
  3958. @b{condition},
  3959. @b{t}
  3960. @subsubheading Description::
  3961. The @i{type} @b{floating-point-overflow} consists of error
  3962. conditions that occur because of floating-point overflow.
  3963. @node floating-point-underflow, , floating-point-overflow, Numbers Dictionary
  3964. @subsection floating-point-underflow [Condition Type]
  3965. @subsubheading Class Precedence List::
  3966. @b{floating-point-underflow},
  3967. @b{arithmetic-error},
  3968. @b{error},
  3969. @b{serious-condition},
  3970. @b{condition},
  3971. @b{t}
  3972. @subsubheading Description::
  3973. The @i{type} @b{floating-point-underflow} consists of
  3974. error conditions that occur because of floating-point underflow.
  3975. @c end of including dict-numbers
  3976. @c %**end of chapter