On this page
math.fmod
Prev: math.fma | Up: math | Next: math.frexp
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.fmod
Tags: #public #python3 #stdlib #math
Import
import math
from math import fmod
Signature & Overview
math.fmod(x, y, /)
Return fmod(x, y), according to platform C.
Usage
import math
assert math.fmod(-7.0, 3.0) == -1.0 # sign follows dividend (-7.0)
assert (-7.0 % 3.0) == 2.0 # Python's % follows divisor (3.0)
Gotchas
- Different sign rule from
%on negative numbers:math.fmodmatches C'sfmod()(sign ofx); Python's%matches the sign ofy.
REPL Inspect
from math import fmod
help(fmod)
Linked from
Related notes
- tuts/python3/stdlib_module/math/fma Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/frexp Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/math/acos Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/acosh Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asin Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asinh Linked here; shared tags: #math, #stdlib
- tuts/c/stdlib/math shared tags: #math, #stdlib
- tuts/c/stdlib/math/fabs shared tags: #math, #stdlib
- tuts/c/stdlib/math/floor shared tags: #math, #stdlib