6 Commits

Author SHA1 Message Date
Sergey B Kirpichev 84bddafd07 Support bin/hex float literals in the CLI
See skirpichev/peps#4 and python/cpython#114667.
2025-05-11 08:58:06 +03:00
Sergey B Kirpichev 9d42919136 Use ast transformation in wrap_float_literals() 2025-04-13 12:37:30 +03:00
Sergey B Kirpichev 2c82152738 Fix source transformation in IPython, add tests 2025-04-13 12:37:27 +03:00
Sergey B Kirpichev 210a6a77da Fix wrap_float_literals() to detect all float/complex literals 2025-04-08 06:01:58 +03:00
Sergey B Kirpichev 551ab3224e CLI fixes for multi-line input
Processing in wrap_float_literals() can't work line-by-line, as the
tokenize.unparse() doesn't preserve indentation in this case.  E.g.:

$ python -m mpmath --no-ipython
>>> def f():
...     return 1.2
...
Traceback (most recent call last):
  ...
  File "<unknown>", line 2
    return mpf('1.2')
    ^^^^^^
IndentationError: expected an indented block after function definition on line 1
2025-04-07 10:49:01 +03:00
Sergey B Kirpichev 5f724296dd Run mpmath as a module for interactive work
Example:
```
$ python -m mpmath --prec 100 --no-ipython
>>> 10.9
mpf('10.899999999999999999999999999995')
>>> mpf(1090/100)
mpf('10.899999999999999999999999999995')
>>> mpf('10.9')
mpf('10.899999999999999999999999999995')
>>> mpf(109)/mpf(10)
mpf('10.899999999999999999999999999995')
>>> mpf(10.9)
mpf('10.899999999999999999999999999995')
```

Closes #677
Closes #765
2024-04-14 10:20:44 +03:00