28.01.2015 Views

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

types.Additionally,theoperations\<strong>and</strong>",\or",<strong>and</strong>\not"aresupported. Booleantypessupportthesameoperationsasunorderedenumeration Thereisapredenedbooleantypecalledpredefined!booleanwhose boolean{association ::=false:named{literal,true:named{literal ::=true:named{literal,false:named{literal 11.<strong>Hermes</strong>Operations103<br />

namedliteralsare'true'<strong>and</strong>'false'.Youc<strong>and</strong>eneyourownboolean typeswithdierentliterals.Example: typedenitiondenesanewintegerdomain. bit:boolean(true:'0',false:'1'); Anintegerdomainconsistsofthemathematicalintegers.Eachinteger<br />

orangesdomain.Butyoucanconvertbetweentwointegerdomainsusing Example:::=realofaccuracyinteger{literal/integer{literal apples:integer; oranges:integer; Asusual,5intheapplesintegerdomaincan'tbecomparedto5inthe type{construction<br />

theconvertoperation. ::=integer<br />

numberthatcantinawordofcomputermemory.Incontrast,<strong>Hermes</strong> usestheusualmathematicaldenitionofinteger.Theresultofaninteger operationisalwayseitherthemathematicallycorrectresult,orelseno discretesubsetofrealnumbersspacedsucientlyclosetogethertomeet asafenumbersuchthattherelativeerror(thedistancebetweenthesafe result<strong>and</strong>aDepletionexception. auser-denedaccuracyrequirement.Foreveryrealnumber,thereexists Insomelanguages\integers"aredenedmodulothesizeofthelargest<br />

number<strong>and</strong>therealnumberdividedbytherealnumber)islessthanor equaltotheaccuracyrequirement. Arealdomainconsistsofasetofsafenumbers.Safenumbersarea<br />

isidenticaltothatshownforintegersabove.Approximaterealarithmetic tegerbetweenthemmusthaveasafeintegerbetweenthem. \preferred"assafenumbers,i.e.anypairofsafenon-integerswithaningrammersaresupported:(1)Zeroisasafenumber,<strong>and</strong>(2)integersare<br />

Theusualrealarithmeticoperationsaresupported;theexpressionsyntax Twootherpropertiesofapproximatearithmeticoftenassumedbypro-<br />

velocity:realofaccuracy1/1000000; Theaccuracyisexpressedasafraction,e.g.1/1000000.Example:<br />

isperformedasfollows.Theresultiscomputed<strong>and</strong>asafenumbernearest theexactresultisusedastheresult.Ifthereismorethanonenearestsafe numbertoanumber,anondeterministicselectionismade.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!