Go to the first, previous, next, last section, table of contents.


Syntax of a Ratio

Ratios can be written as an optional sign followed by two non-empty sequences of digits separated by a slash; see Figure~2--9. The second sequence may not consist entirely of zeros. Examples of ratios are in Figure 2--13.

2/3 ;This is in canonical form 4/6 ;A non-canonical form for 2/3 -17/23 ;A ratio preceded by a sign -30517578125/32768 ;This is (-5/2)^{15 } 10/5 ;The canonical form for this is 2 #o-101/75 ;Octal notation for -65/61 #3r120/21 ;Ternary notation for 15/7 #Xbc/ad ;Hexadecimal notation for 188/173 #xFADED/FACADE ;Hexadecimal notation for 1027565/16435934

Figure 2--13: Examples of Ratios

[Reviewer Note by Barmar: #o, #3r, #X, and #x mentioned above are not in the syntax rules defined just above that.]

For information on how ratios are printed, see section Printing Ratios.


Go to the first, previous, next, last section, table of contents.