float_operations.rst 903 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. .. _float-ops:
  2. Native float operations
  3. ========================
  4. These ``float`` operations have fast, optimized implementations. Other
  5. floating point operations use generic implementations that are often
  6. slower.
  7. Construction
  8. ------------
  9. * Float literal
  10. * ``float(x: int)``
  11. * ``float(x: i64)``
  12. * ``float(x: i32)``
  13. * ``float(x: str)``
  14. * ``float(x: float)`` (no-op)
  15. Operators
  16. ---------
  17. * Arithmetic (``+``, ``-``, ``*``, ``/``, ``//``, ``%``)
  18. * Comparisons (``==``, ``!=``, ``<``, etc.)
  19. * Augmented assignment (``x += y``, etc.)
  20. Functions
  21. ---------
  22. * ``int(f)``
  23. * ``i32(f)`` (convert to ``i32``)
  24. * ``i64(f)`` (convert to ``i64``)
  25. * ``abs(f)``
  26. * ``math.sin(f)``
  27. * ``math.cos(f)``
  28. * ``math.tan(f)``
  29. * ``math.sqrt(f)``
  30. * ``math.exp(f)``
  31. * ``math.log(f)``
  32. * ``math.floor(f)``
  33. * ``math.ceil(f)``
  34. * ``math.fabs(f)``
  35. * ``math.pow(x, y)``
  36. * ``math.copysign(x, y)``
  37. * ``math.isinf(f)``
  38. * ``math.isnan(f)``