float_operations.rst 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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: i16)``
  14. * ``float(x: u8)``
  15. * ``float(x: str)``
  16. * ``float(x: float)`` (no-op)
  17. Operators
  18. ---------
  19. * Arithmetic (``+``, ``-``, ``*``, ``/``, ``//``, ``%``)
  20. * Comparisons (``==``, ``!=``, ``<``, etc.)
  21. * Augmented assignment (``x += y``, etc.)
  22. Functions
  23. ---------
  24. * ``int(f)``
  25. * ``i64(f)`` (convert to 64-bit signed integer)
  26. * ``i32(f)`` (convert to 32-bit signed integer)
  27. * ``i16(f)`` (convert to 16-bit signed integer)
  28. * ``u8(f)`` (convert to 8-bit unsigned integer)
  29. * ``abs(f)``
  30. * ``math.sin(f)``
  31. * ``math.cos(f)``
  32. * ``math.tan(f)``
  33. * ``math.sqrt(f)``
  34. * ``math.exp(f)``
  35. * ``math.log(f)``
  36. * ``math.floor(f)``
  37. * ``math.ceil(f)``
  38. * ``math.fabs(f)``
  39. * ``math.pow(x, y)``
  40. * ``math.copysign(x, y)``
  41. * ``math.isinf(f)``
  42. * ``math.isnan(f)``