aboutsummaryrefslogtreecommitdiff
path: root/theories/Init/Decimal.v
AgeCommit message (Collapse)Author
2020-11-05[numeral notation] QPierre Roux
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).
2020-09-11Rename Numeral Notation command to Number NotationPierre Roux
Keep Numeral Notation wit a deprecation warning.
2020-05-09Decimal: prove numeral notation for QPierre Roux
Fill in the proofs, adding a few neessary lemmas along the way.
2020-05-01Fixing #11903: Fixpoints not truly recursive in standard library.Hugo Herbelin
There was also a non truly recursive in the doc.
2020-03-25Nicer printing for decimal constants in QPierre Roux
Print 1.5 as 1.5 and not 15e-1. We choose the shortest representation with tie break to the dot notation (0.01 rather than 1e-3). The printing remains injective, i.e. 12/10 is not mixed with 120/100, the first being printed as 1.2 and the last as 1.20.
2020-03-18Update headers in the whole code base.Théo Zimmermann
Add headers to a few files which were missing them.
2019-06-17Update ml-style headers to new year.Théo Zimmermann
2019-04-02Add parsing of decimal constants (e.g., 1.02e+01)Pierre Roux
Rather than integers '[0-9]+', numeral constant can now be parsed according to the regexp '[0-9]+ ([.][0-9]+)? ([eE][+-]?[0-9]+)?'. This can be used in one of the two following ways: - using the function `Notation.register_rawnumeral_interpreter` in an OCaml plugin - using `Numeral Notation` with the type `decimal` added to `Decimal.v` See examples of each use case in the next two commits.
2019-01-25[Numeral notations] Use Coqlib registered constantsVincent Laporte
2018-09-10Adapting standard library to the introduction of "Declare Scope".Hugo Herbelin
Removing in passing two Local which are no-ops in practice.
2018-08-31Decimal: scope name changed dec_(u)int_scopePierre Letouzey
This avoid a clash with int_scope in ssreflect's ssrint.v
2018-08-31Numeral Notation: allow parsing from/to Decimal.int or Decimal.uintPierre Letouzey
This way, we could fully bypass bigint.ml. The previous mechanism of parsing/printing Z is kept for now. Currently, the conversion functions accepted by Numeral Notation foo may have the following types. for parsing: int -> foo int -> option foo uint -> foo uint -> option foo Z -> foo Z -> option foo for printing: foo -> int foo -> option int foo -> uint foo -> option uint foo -> Z foo -> option Z Notes: - The Declare ML Module is directly done in Prelude - When doing a Numeral Notation, having the Z datatype around isn't mandatory anymore (but the error messages suggest that it can still be used). - An option (abstract after ...) allows to keep large numbers in an abstract form such as (Nat.of_uint 123456) instead of reducing to (S (S (S ...))) and ending immediately with Stack Overflow. - After checking with Matthieu, there is now a explicit check and an error message in case of polymorphic inductive types
2018-02-27Update headers following #6543.Théo Zimmermann
2018-02-20Decimal: proofs that conversions from/to nat,N,Z are bijectionsPierre Letouzey
2018-02-20Decimal: simple representation of base-10 numbersPierre Letouzey