Math Functions

math.copysign()

Combine the magnitude of the first value with the sign of the second, including signed zero.

Formal Syntax & Structure

python syntaxpython
math.copysign(x, y, /)

Parameters & Attributes

NameTypeDescription
xreal numberInput real value.
yreal numberSecond real value.

Return Value

float

Floating-point result; finite precision and domain restrictions apply.

Working Example

Example Snippetpython
import mathprint(math.copysign(8, -0.0))
Python Reference