diff options
| author | Pierre Roux | 2020-09-03 13:16:00 +0200 |
|---|---|---|
| committer | Pierre Roux | 2020-11-05 00:20:19 +0100 |
| commit | ec24b26be7795af27256d39431e1c4e3d42fe3b7 (patch) | |
| tree | 6e6e586f0507043994bcc6e59503059201e46f7b /plugins/syntax/r_syntax_plugin.mlpack | |
| parent | 7ea7834b442cbfbf3299536020cb033702b2535c (diff) | |
[numeral notation] Q
Previously rationals were all parsed as a pair numerator, denominator.
This means 1.02 and 102e-2 were both parsed as 102 # 100 and could not
be tell apart when printing. So the printer had to choose between two
representations : without exponent or without decimal dot. The choice
was made heuristically toward a most compact representation.
Now, decimal dot is still parsed as a power of ten denominator but
exponents are parsed as a product or division by Z.pow_pos. For
instance, 1.02 is parsed as 102 # 100 whereas 102e-2 is parsed as
(102 # 1) / (Z.pow_pos 10 2 # 1).
1.02 and 102e-2 remain equal (proved by reflexivity) but 1.02e1
= (102 # 100) * (10 # 1) = 1020 # 100 and 10.2 = 102 # 10 no longer are.
A nice side effect is that exponents can no longer blow up during
parsing. Previously 1e1_000_000 literally produced a numerator with a
million digits, now it just yields (1 # 1) * (Z.pow_pos 10 1_000_000 # 1).
Diffstat (limited to 'plugins/syntax/r_syntax_plugin.mlpack')
0 files changed, 0 insertions, 0 deletions
