File: float_operations.rst

package info (click to toggle)
mypy 1.15.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 20,576 kB
  • sloc: python: 105,159; cpp: 11,380; ansic: 6,629; makefile: 247; sh: 20
file content (50 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
.. _float-ops:

Native float operations
========================

These ``float`` operations have fast, optimized implementations. Other
floating point operations use generic implementations that are often
slower.

Construction
------------

* Float literal
* ``float(x: int)``
* ``float(x: i64)``
* ``float(x: i32)``
* ``float(x: i16)``
* ``float(x: u8)``
* ``float(x: str)``
* ``float(x: float)`` (no-op)

Operators
---------

* Arithmetic (``+``, ``-``, ``*``, ``/``, ``//``, ``%``)
* Comparisons (``==``, ``!=``, ``<``, etc.)
* Augmented assignment (``x += y``, etc.)

Functions
---------

* ``int(f)``
* ``i64(f)`` (convert to 64-bit signed integer)
* ``i32(f)`` (convert to 32-bit signed integer)
* ``i16(f)`` (convert to 16-bit signed integer)
* ``u8(f)`` (convert to 8-bit unsigned integer)
* ``abs(f)``
* ``math.sin(f)``
* ``math.cos(f)``
* ``math.tan(f)``
* ``math.sqrt(f)``
* ``math.exp(f)``
* ``math.log(f)``
* ``math.floor(f)``
* ``math.ceil(f)``
* ``math.fabs(f)``
* ``math.pow(x, y)``
* ``math.copysign(x, y)``
* ``math.isinf(f)``
* ``math.isnan(f)``