Sideway
output.to from Sideway
Draft for Information Only

Content

Python Integer Manipulation
 Fuction int()
  Syntax
 Function round()
  Syntax
 Fuction numpy.ceil()
  Syntax
 Function numpy.floor()
  Syntax
 Function numpy.fix()
  Syntax
 Function numpy.trunc()
  Syntax
 Function numpy.rint()
  Syntax
 Summarized Examples"
 Source and Reference

Python Integer Manipulation

Fuction int()

Return an integer object constructed from a number or string x, or return 0 if no arguments are given. If x defines __int__(), int(x) returns x.__int__(). If x defines __index__(), it returns x.__index__(). If x defines __trunc__(), it returns x.__trunc__(). For floating point numbers, this truncates towards zero. If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in radix base. Optionally, the literal can be preceded by + or - (with no space in between) and surrounded by whitespace. A base-n literal consists of the digits 0 to n-1, with a to z (or A to Z) having values 10 to 35. The default base is 10. The allowed values are 0 and 2–36. Base-2, -8, and -16 literals can be optionally prefixed with 0b/0B, 0o/0O, or 0x/0X, as with integer literals in code. Base 0 means to interpret exactly as a code literal, so that the actual base is 2, 8, 10, or 16, and so that int('010', 0) is not legal, while int('010') is, as well as int('010', 8).

Syntax

class int([x])
class int(x, base=10)

Function round()

Return number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input. For the built-in types supporting round(), values are rounded to the closest multiple of 10 to the power minus ndigits; if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2). Any integer value is valid for ndigits (positive, zero, or negative). The return value is an integer if ndigits is omitted or None. Otherwise the return value has the same type as number.

Syntax

round(number[, ndigits])

Fuction numpy.ceil()

Return the ceiling of the input, element-wise. The ceil of the scalar x is the smallest integer i, such that i >= x. It is often denoted as ⌈x⌉.

Syntax

numpy.ceil(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'ceil'>

Function numpy.floor()

Return the floor of the input, element-wise. The floor of the scalar x is the largest integer i, such that i <= x. It is often denoted as ⌊x⌋.

Syntax

numpy.floor(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'floor'>

Function numpy.fix()

Round to nearest integer towards zero. Round an array of floats element-wise to nearest integer towards zero. The rounded values are returned as floats.

Syntax

numpy.fix(x, out=None)

Function numpy.trunc()

Return the truncated value of the input, element-wise. The truncated value of the scalar x is the nearest integer i which is closer to zero than x is. In short, the fractional part of the signed number x is discarded.

Syntax

numpy.trunc(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'trunc'>

Function numpy.rint()

Round elements of the array to the nearest integer.

Syntax

numpy.rint(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'rint'>

Summarized Examples"

Number-2.0-1.7-1.6-1.5-1.4-1.0-0.7-0.20.00.20.71.01.41.51.61.72.0n+ int-2-1-1-1-1-100000111112.0 round-2-2-2-2-1-1-10001112222.5 numpy.ceil-2.-1.-1.-1.-1.-1.-0.-0.0.1.1.1.2.2.2.2.2..0 numpy.floor-2.-2.-2.-2.-2.-1.-1.-1.0.0.0.1.1.1.1.1.2..0 numpy.fix-2.-1.-1.-1.-1.-1.-0.-0.0.0.0.1.1.1.1.1.2..0 numpy.trunc-2.-1.-1.-1.-1.-1.-0.-0.0.0.0.1.1.1.1.1.2..0 numpy.rint-2.-2.-2.-2.-1.-1.-1.-0.0.0.1.1.1.2.2.2.2..5

Source and Reference

  • https://docs.python.org/3/library/functions.html
  • https://numpy.org/doc/1.21/
  • https://numpy.org/doc/1.21/numpy-ref.pdf
  • https://numpy.org/doc/stable/reference/generated/numpy.ceil.html
  • https://numpy.org/doc/stable/reference/generated/numpy.fix.html#numpy.fix
  • https://numpy.org/doc/stable/reference/generated/numpy.trunc.html#numpy.trunc
  • https://numpy.org/doc/stable/reference/generated/numpy.rint.html#numpy.rint
  • https://numpy.org/doc/stable/reference/generated/numpy.floor.html#numpy.floor

©sideway

ID: 210900017 Last Updated: 9/17/2021 Revision: 0


Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Set 1

Logic 1

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019