3e2 is equivalent to 3*10^2. When mixing shorthands, decimal point and scientific for example, we must choose which is obeyed first. Conventionally, the decimal separator always has the highest precedence, followed by negative signs second and the scientific exponent last.J extends numeric shorthands so that compound numbers may be written with ease.
. decimal separator. _ negative sign. r exact ratio, quotient. e scientific notation. ad ar j complex magnitude of degree angles or radian angles, complex. p x pi times(apb = a*pi^b), Euler's number(axb = a*e^b). b base representation(2b110 = 5).
The letters are ordered in order of decreasing precedence, the decimal separator being obeyed first. Letters on the same line have the same precedence, there is no associativity so two letters with the same precedence may not be in the same numeric expression.
Some examples of applying these shorthands:
2e2j2p1
628.319j6.28319
2e2j_2e2
200j_200
The numeric constants constitute an LL(1) grammar.
E0 -> E1$ E1 -> E2 b E2 E2 -> E3 p E3 | x E3 E3 -> E4 ad E4 | ar E4 | j E4 E4 -> E5 e E5 E5 -> E6 r E6 E6 -> _ E7 E7 -> E8 . E8 E8 -> num
(Elaboration on types)
No comments:
Post a Comment