Sideway
output.to from Sideway
Draft for Information Only

Content

Python Numeric Literal
 Integer Literal
  Definition of Integer Literal
  Features of Integer
  Python Integer Catalogue
 Floating Point Literal
  Definition of Floating Point Literal
  Features of Floating Point
  Python Floating Point Catalogue
 Imaginary Literal
  Definition of Imaginary Literal
  Features of Imaginary
 Source and Reference

Python Numeric Literal

Python supports numeric literals of integers, floating point numbers, and imaginary numbers. Complex literal is formed by adding a real number and an imaginary number. Besides, numeric sign is not included in numeric literal, but numeric sign '-' or '+' is considered as an unary operator - or +.

Integer Literal

An integer literal is a sequence of ASCII characters.

Definition of Integer Literal

The definition of integer literal is: integer::=decinteger | bininteger | octinteger | hexinteger decinteger::=nonzerodigit (["_"] digit)* | "0"+ (["_"] "0")* bininteger::="0" ("b" | "B") (["_"] bindigit)+ octinteger::="0" ("o" | "O") (["_"] octdigit)+ hexinteger::="0" ("x" | "X") (["_"] hexdigit)+ nonzerodigit::="1"..."9" digit::="0"..."9" bindigit::="0" | "1" octdigit::="0"..."7" hexdigit::=digit | "a"..."f" | "A"..."F"

Features of Integer

Leading zeros in a non-zero decimal number are not allowed. The length of integer literal is unlimited and is only limited by available memory. Therefore, long integer type is no longer necessary. Underscores _ are only used to group digits for enhancing readability and underscores are ignored for determining the numeric value of the literal. One underscore can occure between digits, but must be placed after base specifiers like 0x.

Python Integer Catalogue

Python integer can be divided into decinteger, bininteger, octinteger, and hexinteger. decintegerLeading zeros in a non-zero decimal literal are not allowed to prevent disambiguation with C-style octal literals. Underscore _ can be placed in between any two decimal characters of an integer literal. Decimal characters can be any nonzerodigit, "1"..."9" and digit, "0"..."9". image binintegerThe base specifiers for binary integer are 0b and 0B. Underscore _ can be placed in between any two binary characters of an bininteger literal after the base specifier. Binary characters after base specifier can be any bindigit, "0" | "1" after the base specifier. image octintegerThe base specifiers for octal integer are 0o and 0O. Underscore _ can be placed in between any two octal characters of an octinteger literal after the base specifier. Octal characters after base specifier can be any octinteger, "0"..."7" image hexintegerThe base specifiers for hexadecimal integer are 0x and 0X. Underscore _ can be placed in between any two hexadecimal characters of an hexinteger literal after the base specifier. Hexadecimal characters after base specifier can be any hexdigit, "0"..."9" | "a"..."f" | "A"..."F" image

Floating Point Literal

A floating point literal is a sequence of characters for representing an floating point number with an integer part, a fractional part, and an exponent part.

Definition of Floating Point Literal

The definition of floating point literal is: floatnumber::=pointfloat | exponentfloat pointfloat::=[digitpart] fraction | digitpart "." exponentfloat::=(digitpart | pointfloat) exponent digitpart::=digit (["_"] digit)* fraction::="." digitpart exponent::=("e" | "E") ["+" | "-"] digitpart

Features of Floating Point

Leading zeros in a floating point literal are allowed because the integer and exponent parts are always interpreted using radix 10. The allowed range of floating point literals is implementation-dependent. Underscores _ are only used to group digits for enhancing readability and underscores are ignored for determining the numeric value of the literal. One underscore can occure between numeric digits.

Python Floating Point Catalogue

pointfloatDecimal point . is used together with digits to present the floating point literal. A pointfloat is always composed of a digitpart and a fraction. A fraction is specified by a decimal point .. Therefore decimal point . can be placed at the end of floating point literal to indicate a floating point literal. Leading zeros in a floating point literal are allowed. Underscores _ are only used to group digits for enhancing readability and underscores are ignored for determining the numeric value of the literal. One underscore can occure between numeric digits image exponentfloatExponent e or E is used together with digits to present the floating point literal. For a exponentfloat, the exponent part must be included in the floating point literal, while digit part of a floating point literal can be a pointfloat or simple digitpart. A exponent is specified by a character e or E followed only by a digitpart and a sign operator + or - can be added before the digitpart. image image

Imaginary Literal

An imaginary literal is a sequence of characters for representing an imaginary number of the imaginary part of a complex number.

Definition of Imaginary Literal

The definition of imaginary literal is: imagnumber::=(floatnumber | digitpart) ("j" | "J")

Features of Imaginary

An imagnumber is actually a floatnumber or digitpart with a imaginary specifier j or J. In other words, an imagnumber have the same proerties and restrictions as a floatnumber or digitpart. An imaginary literal can be used to construct a complex number by adding a floating point number to it. image

Source and Reference


©sideway

ID: 210100004 Last Updated: 1/4/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

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