On this page
  1. math.copysign
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

math.copysign

Prev: math.comb | Up: math | Next: math.cos
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.copysign
Tags: #public #python3 #stdlib #math


Import

import math
from math import copysign

Signature & Overview

math.copysign(x, y, /)

Return a float with the magnitude (absolute value) of x but the sign of y.

Usage

import math

assert math.copysign(3.5, -1.0) == -3.5
assert math.copysign(-3.5, 0.0) == 3.5

Gotchas

REPL Inspect

from math import copysign
help(copysign)

Linked from

Related notes