frexp

paddle. frexp ( x: Tensor, name: str | None = None, *, out: tuple[Tensor, Tensor] | None = None ) → tuple[Tensor, Tensor] [source]

The function used to decompose a floating point number into mantissa and exponent.

Parameters
  • x (Tensor) – The input tensor, it’s data type should be float32, float64. Alias: input.

  • name (str|None, optional) – For details, please refer to api_guide_Name. Generally, no setting is required. Default: None.

Keyword Arguments

out (tuple[Tensor, Tensor]|None, optional) – The output tuple of tensors. If provided, the result will be assigned to the tensors in the tuple. The first tensor stores mantissa, the second tensor stores exponent. Default: None.

Returns

  • mantissa (Tensor), A mantissa Tensor. The shape and data type of mantissa tensor and exponential tensor are

    the same as those of input.

  • exponent (Tensor), A exponent Tensor. The shape and data type of mantissa tensor and exponential tensor are

    the same as those of input.

Examples

>>> import paddle

>>> x = paddle.to_tensor([[1, 2, 3, 4]], dtype="float32")
>>> mantissa, exponent = paddle.tensor.math.frexp(x)
>>> mantissa
Tensor(shape=[1, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[0.50000000, 0.50000000, 0.75000000, 0.50000000]])
>>> exponent
Tensor(shape=[1, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[1., 2., 2., 3.]])